我不太确定我搞砸了什么。我已经设法用basic A-Frame编写了自己的组件,但自从迁移到aframe-react之后,我就遇到了这个错误:
Error in ./src/components.js
C:\PATH_TO\src\components.js
1:1 error 'AFRAME' is not defined no-undefcomponents.js:
AFRAME.registerComponent('pointer_click', {
// ...
});我是不是导入错了?
import 'aframe';
import 'aframe-animation-component';
import 'aframe-particle-system-component';
import 'babel-polyfill';
import {Entity, Scene} from 'aframe-react';
import React from 'react';
import ReactDOM from 'react-dom';
import './components.js';发布于 2018-01-13 22:24:33
如果你使用的是create-react-app,那么你需要遵循这个create-react-app-global-vars来引用'AFRAME‘作为一个全局变量。
基本上,将它包含在AFrame组件文件的顶部。
const AFRAME = window.AFRAME;发布于 2017-09-19 06:31:54
也许这只是一个lint错误或bundler错误?你用的是什么捆绑器?我想知道你是否必须在某个地方将AFRAME声明为全局变量(例如,顶部的/* globals AFRAME */ ),或者在某些配置中将AFRAME定义为全局变量。
如果你可能正在使用semistandard linter,你可以输入package.json:
"semistandard": {
"globals": [
"AFRAME",
"THREE"
],
"ignore": [
"build/**"
]
}https://stackoverflow.com/questions/46254011
复制相似问题