我不太确定我在这里搞砸了什么。我已经成功地在基本 A-Frame 中编写了自己的组件,但自从转向 aframe-react 后,我收到了错误:
Error in ./src/components.js
C:\PATH_TO\src\components.js
1:1 error 'AFRAME' is not defined no-undef
组件.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';
最佳答案
如果您使用的是create-react-app,那么您需要遵循此create-react-app-global-vars将“AFRAME”引用为全局变量。
基本上,将其包含在 AFrame 组件文件的顶部。
const AFRAME = window.AFRAME;
关于javascript - aframe- react ;写入新组件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46254011/