SystemJS:加载 jQuery

问题描述 投票:0回答:1

我正在使用 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';

我尝试使用地图而不是路径,但结果相同..

jquery angular systemjs
1个回答
1
投票

正确的代码是:

import * as $ from 'jQuery';

您还应该映射到 CDN 吗?

为什么不通过 NodeJS 获取 jQuery 或将 jQuery 保存在本地并映射到它?

© www.soinside.com 2019 - 2024. All rights reserved.