我正在使用 Angular2,并且我想包含 jQuery。
systemjs.config.js
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/',
'jquery': "//code.jquery.com/jquery-2.1.4.min.js"
},
meta: {
bootstrap: {
deps: ['jquery']
}
},
.....
}
在app.module.ts中,我收到错误:当我放置时找不到模块“jquery”:
import $ from 'jquery';
我尝试使用地图而不是路径,但结果相同..
正确的代码是:
import * as $ from 'jQuery';
您还应该映射到 CDN 吗?
为什么不通过 NodeJS 获取 jQuery 或将 jQuery 保存在本地并映射到它?