簡體   English   中英

jQuery中的錯誤未定義webpack和imports-loader

[英]ERROR in jQuery is not defined webpack and imports-loader

嘗試添加jquery庫時出現此錯誤。

{
   test: require("path").resolve("./main/static/src/application.js"),
   loader: 'imports-loader?this=>window,$=jquery!./main/static/src/vendor/jquery-ui/ui/widgets/draggable.js'
}

new webpack.ProvidePlugin({
    $: "jquery",
    jQuery: "jquery",
    'window.jQuery': 'jquery',
    'window.$': 'jquery',
    io: 'socket.io-client',
    _:'underscore',
    moment:"moment",
})

錯誤:

ERROR in jQuery is not defined

看來有幾種方法可以解決此問題,我選擇了暴露加載器

{
  test: require.resolve('jquery'),
  use: [
   'expose-loader?jQuery',
   'expose-loader?$'
  ]
},

查看更多詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM