我不确定我在这里搞砸了什么。我已经设法在基本的A-Frame中编写自己的组件,但是由于转向aframe-react我得到了错误:
Error in ./src/components.js
C:\PATH_TO\src\components.js
1:1 error 'AFRAME' is not defined no-undef
components.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';
答案 0 :(得分:0)
也许这只是一个lint错误或捆绑错误?你使用什么捆绑器?我想知道你是否必须在某个地方声明/* globals AFRAME */
为全局(例如,顶部为AFRAME
)或在某些配置中将semistandard
定义为全局。
如果你可能使用"semistandard": {
"globals": [
"AFRAME",
"THREE"
],
"ignore": [
"build/**"
]
}
linter,你可以输入package.json:
{{1}}
答案 1 :(得分:0)
如果您使用的是create-react-app,则需要按照此create-react-app-global-vars引用' AFRAME'作为一个全局变量。
基本上,请将其包含在AFrame组件文件的顶部。
const AFRAME = window.AFRAME;