7
经过几个小时的搜索和测试。我终于放弃了。我正在使用带有webpack的Angular2,我尝试在我的angular2应用程序中使用three.js。我已经安装了npm包@type/3我怎样才能导入@类型/三角2
sudo npm install @types/three --save
而且我用多种方式编辑了我的tsconfig.json。我甚至试图在polyfills.browser.ts中添加“three/three”导入。但我不断收到解决模块错误。也许有什么毛病我tsconfig.json如下
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"typeRoots": [
"./node_modules/@types"
],
"types": [
"core-js",
"node",
"three"
]
},
"exclude": [
"node_modules"
],
"awesomeTypescriptLoaderOptions": {
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
,我已经至少在我试图成分的语法如下
import {THREE} from "@types/three";
import {THREE} from "three";
import "@types/three";
import "three";
import * as _ from "@types/three";
import * as _ from "three";
其实我真的不明白怎么所有这些tsconfig, webpackconfig工作,所以当我尝试实现这个@ types /模块时,我不知道我在做什么。任何帮助将不胜感激,谢谢!
非常感谢您!看起来像npm三个包是我所缺少的,我向我的“依赖关系”和@ types/3添加了三个到我的“devDependencies”,我也没有添加任何东西到我的wwebpack.config.js,它的工作。在我的webpack.config.js中添加了三个:'npm:/three/build/three.min.js'到defaultConfig后。它也在工作,所以我不知道我想用我的webpack.config.js做什么。你能解释一下吗?非常感谢! – mok
更新。在tsconfig.json中,我在{“compilerOptions”中添加“three”:{“types”:[“three”]}}。因此,当新的THREE.Scene()时,我的PHPStorm不会报告错误。 – mok
我不得不将“requestAnimationFrame(this.animate);”与“requestAnimationFrame(this.animate.bind(this));”在测试组件中。 – blue