简体   繁体   中英

webpack can't use jQuery by ProvidePlugin

My webpack config file adds following code:

plugins: [
     new webpack.ProvidePlugin({
       jQuery: 'jquery',
       $: 'jquery'
     }),
     ...

I could use $() function but can't use jQuery() function on my project.

Has anyone ever faced such problem?

Try adding window.jQuery

new webpack.ProvidePlugin({
   $: 'jquery',
   jQuery: 'jquery',
   'window.jQuery': 'jquery',
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM