【发布时间】:2016-04-18 16:37:21
【问题描述】:
我有一个 Aurelia 应用,我想在 app.js 中使用 jQuery。
所以我的 config.js 看起来像:
System.config({
...
map: {
...
"jquery": "npm:jquery@2.2.0",
...
}
}
在 app.js 中,我像这样导入 jQuery:
var $ = require('jquery');
但是当我需要它时,我会得到空白站点。与导入相同:
import $ from 'jquery';
怎么了?
谢谢
编辑: 好的,解决了。问题是,必须在 attach() 方法中调用 jQuery 代码。像这样:
export class Class1 {
attached() {
//jQuery code here
}
}
【问题讨论】:
标签: javascript jquery aurelia