[英]How to use external libraries in Angular Class Starter
In my app, I want to use dropzone.js 在我的应用中,我想使用dropzone.js
So, I installed dropzone by npm install --save-dev dropzone
所以,我通过
npm install --save-dev dropzone
And I include import this library in my polyfills.browser.ts
file 我在我的
polyfills.browser.ts
文件中包括导入该库
/**
* Added parts of es6 which are necessary for your project or your browser support requirements.
*/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/weak-map';
import 'core-js/es6/weak-set';
import 'core-js/es6/typed';
import 'core-js/es6/reflect';
/**
* See issue https://github.com/AngularClass/angular2-webpack-starter/issues/709
*/
/* import 'core-js/es6/promise'; */
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
import 'dropzone';
And I also installed '@types/dropzone'. 而且我还安装了“ @ types / dropzone”。
But this is not work properly throwing error like this. 但这不能正常工作,并抛出这样的错误。
[at-loader] ./node_modules/@types/jquery/index.d.ts:4482:65
TS2314: Generic type 'Event<TTarget, EventTarget, TData>' requires 3 type argument(s).
[at-loader] ./node_modules/@types/jquery/index.d.ts:4483:20
TS2314: Generic type 'PlainObject<T, any>' requires 2 type argument(s).
[at-loader] ./node_modules/@types/jquery/index.d.ts:4483:49
TS2314: Generic type 'Event<TTarget, EventTarget, TData>' requires 3 type argument(s).
[at-loader] ./node_modules/@types/jquery/index.d.ts:4487:46
TS2531: Object is possibly 'null'.
[at-loader] ./node_modules/@types/jquery/index.d.ts:4487:52
TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures.
[at-loader] ./node_modules/@types/jquery/index.d.ts:4488:10
TS2331: 'this' cannot be referenced in a module or namespace body.
[at-loader] ./node_modules/@types/jquery/index.d.ts:4488:16
TS2304: Cannot find name 'TContext'.
I don't know what's the matter. 我不知道怎么了 What is the missing concepts that I don't know?
我不知道缺少哪些概念?
Open tsconfig.webpack.json
and add: 打开
tsconfig.webpack.json
并添加:
"skipLibCheck": true
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmit": true,
"noEmitHelpers": true,
"importHelpers": true,
"strictNullChecks": false,
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"hammerjs",
"node"
]
},
Unrelated to the answer. 与答案无关。 But you should use
--save
and not --save-dev
for dependencies required for the application to run. 但是对于应用程序运行所需的依赖项,应使用
--save
而不是--save-dev
。 Also I recommend using the Angular CLI , this starter is not maintained as well as it used to be. 另外,我建议使用Angular CLI ,此启动器无法像以前那样得到维护。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.