我试过这个:
import $ from 'jquery';
window.jQuery = $;
import angular from 'angular';
但 $.fn.scope 未定义且 ng-bind-html 中的脚本不起作用 Injecting a script tag with ngBindHtml
也在 webpack 配置中尝试过这个
module.exports = {
module: {
loaders: [
{ test: /angular(\.min)?\.js$/, loader: "imports?$=jquery" },
{ test: /jquery(\.min)?\.js$/, loader: 'expose?jQuery' }
]
}
};
但出现错误:
ERROR in ./~/angular/angular.js
Module not found: Error: Cannot resolve module 'expose' in C:\project\src\ui\node_modules\angular
@ ./~/angular/angular.js 2:8-25
最佳答案
这项工作:
module.exports = {
module: {
loaders: [
{ test: /angular(\.min)?\.js$/, loader: "imports?$=jquery" },
{ test: /jquery(\.min)?\.js$/, loader: 'expose?jQuery' }
]
}
};
但是你需要从 npm 安装 expose-loader
:
npm install expose-loader --save
关于javascript - 如何在带有 ES6 的 webpack 中的 Angular 之前包含 jQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39080379/