无法将 A 型框架导入组件 - Angular2
Can't import A-frame into component - Angular2
我有一个用 angular-cli
创建的项目,我通过 npm install aframe --save
安装了 aframe
,当我尝试通过 import 'aframe';
将它导入组件时,它导致以下错误:
Failed to execute registerElement
on Document
: Registration failed for type a-node
. A type with that name is already registered.
在这种情况下,使其工作的唯一方法是在 index.html
文件的 <head>
标记中导入库。相反,我想访问 aframe
object3D 到 modify 对象实体,如下所示:
AFRAME.registerComponent('foo', {
init: function () {
// Do something
}
});
但不幸的是我无法让它工作。你知道如何解决这个问题吗?预先感谢您的回复!
以下是让它在 Angular2 中正常工作的条件:
- 编辑您的 angular-cli.json 并将路径添加到脚本节点:
"scripts": [
"node_modules/aframe/dist/aframe-master.js"
],
从 https://github.com/devpaul/aframe-typings/blob/master/src/AFRAME.d.ts 下载打字。
在您的组件中引用类型:
/// <reference path="../typings/AFRAME.d.ts" />
或在您的 tsconfig.json:
中全局安装打字
"files": [
"typings/AFRAME.d.ts"
]
我有一个用 angular-cli
创建的项目,我通过 npm install aframe --save
安装了 aframe
,当我尝试通过 import 'aframe';
将它导入组件时,它导致以下错误:
Failed to execute
registerElement
onDocument
: Registration failed for typea-node
. A type with that name is already registered.
在这种情况下,使其工作的唯一方法是在 index.html
文件的 <head>
标记中导入库。相反,我想访问 aframe
object3D 到 modify 对象实体,如下所示:
AFRAME.registerComponent('foo', {
init: function () {
// Do something
}
});
但不幸的是我无法让它工作。你知道如何解决这个问题吗?预先感谢您的回复!
以下是让它在 Angular2 中正常工作的条件:
- 编辑您的 angular-cli.json 并将路径添加到脚本节点:
"scripts": [
"node_modules/aframe/dist/aframe-master.js"
],
从 https://github.com/devpaul/aframe-typings/blob/master/src/AFRAME.d.ts 下载打字。
在您的组件中引用类型:
/// <reference path="../typings/AFRAME.d.ts" />
或在您的 tsconfig.json:
中全局安装打字"files": [
"typings/AFRAME.d.ts"
]