我试图找到一种方法来在我的angular2 +应用中包含第三方库(urijs)。下面你会发现有关的文件。如何将URI.js库包含在Angular2 +应用程序中?
// package.json
{
...
"dependencies": {
...
"urijs": "^1.18.10",
...
}
...
}
// .angular-cli.json
{
...
"scripts": ["../node_modules/urijs/src/URI.js"],
...
}
// file.service.js
declare const URI: any;
...
...
URI.expand(..);
这样做,我在运行我的应用程序时出错。
ERROR TypeError: URI.expand is not a function
at ProfileService.webpackJsonp.../../../../../src/app/shared/trakt/users/profile.service.ts.ProfileService.retrieveProfile (main.bundle.js:1071)
at HeaderComponent.webpackJsonp.../../../../../src/app/home/header/header.component.ts.HeaderComponent.ngOnInit (main.bundle.js:239)
at checkAndUpdateDirectiveInline (vendor.bundle.js:59912)
at checkAndUpdateNodeInline (vendor.bundle.js:61408)
at checkAndUpdateNode (vendor.bundle.js:61347)
at debugCheckAndUpdateNode (vendor.bundle.js:62208)
at debugCheckDirectivesFn (vendor.bundle.js:62149)
at Object.eval [as updateDirectives] (ng:///HomeModule/HomeComponent.ngfactory.js:13)
at Object.debugUpdateDirectives [as updateDirectives] (vendor.bundle.js:62134)
at checkAndUpdateView (vendor.bundle.js:61314)
任何想法,我怎么能包括urijs库?
感谢
我发现这个库有一个[类型文件](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/urijs)。 – Ismael