SystemJS: loading jQuery

自作多情 提交于 2019-12-11 01:34:23

问题


I'm using Angular2, and I'd like to include 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']
    }
 },
.....
}

In app.module.ts, I got the error : Cannot find the module 'jquery' when I put :

import $ from 'jquery';

I try it using map instead of paths, but the same result..


回答1:


The correct code is ..

import * as $ from 'jQuery';

Also should u be mapping to a CDN?

When not get jQuery via NodeJS or save jQuery locally and map to it?



来源:https://stackoverflow.com/questions/40236090/systemjs-loading-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!