[英]Using JQuery in angular asp.net core application
I am trying to use bootstrap methods in a custom directive in an asp.net core angular web application. 我正在尝试在asp.net核心angular Web应用程序的自定义指令中使用引导方法。 However, when I run the application, I get the error message "'jQuery' is undefined" in main-client.js.
但是,当我运行该应用程序时,在main-client.js中收到错误消息“'jQuery'is undefined”。
If I change webpack.config.js to add the webPack.ProvidePlugin plugin, the problem goes away. 如果我更改webpack.config.js以添加webPack.ProvidePlugin插件,则问题就消失了。
module.exports = (env) => {
...
const sharedConfig = {
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new CheckerPlugin()
]
};
...
};
However, this plugin already exists in webpack.config.vendor.js. 但是,此插件已存在于webpack.config.vendor.js中。 Why do I need to add it again?
为什么需要再次添加?
Hello you can add this loader : 您好,您可以添加此加载程序:
/**
* Special loading issue. to expose something as window.something in browser side.
*
* Reference : https://github.com/webpack-contrib/expose-loader
*/
{ test: require.resolve("jquery"), loader: "expose-loader?$!expose-loader?jQuery" }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.