大家好,我正在使用 Vue.js CLI
我正在关注这篇文章:https://65535th.com/jquery-plugins-and-webpack/关于将 Jquery 插件添加到 webpack 项目中。
我安装了公开加载程序并将以下行添加到我的 webpack.base.conf.js
{ test: /jquery/, loader: 'expose?$!expose?jQuery!expose?jquery' }
然后在我的 main.js(应用程序的入口点)中添加了以下两行以引入 Jquery 库,然后引入 Kendo 库。
import '../bower_components/jquery/dist/jquery.js';
import '../bower_components/kendo-ui/js/kendo.all.min.js';
然后我运行 npm run dev ,它会启动一切并生成以下输出(请注意,恢复和运行需要花费大量时间)
[BABEL] Note: The code generator has deoptimised the styling of "/var/www/public/kendo/bower_components/kendo-ui/js/kendo.all.min.js" as it exceeds the max of "100KB".
webpack: wait until bundle finished: /__webpack_hmr
[BABEL] Note: The code generator has deoptimised the styling of "/var/www/public/kendo/bower_components/jquery/dist/jquery.js" as it exceeds the max of "100KB".
webpack built 6459c5d00452a152a319 in 405389ms
Hash: 6459c5d00452a152a319
Version: webpack 1.13.0
Time: 405389ms
Asset Size Chunks Chunk Names
app.js 14.8 MB 0 app
ERROR in ./bower_components/kendo-ui/js/kendo.all.min.js
Module not found: Error: Cannot resolve module 'jquery' in /var/www/public/kendo/bower_components/kendo-ui/js
@ ./bower_components/kendo-ui/js/kendo.all.min.js 1:1022-1059
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 21.4 kB 0
webpack: bundle is now VALID.
为什么缺少jquery?我是否做错了某种配置?感谢您的帮助。
最佳答案
JavaScript 区分大小写。我用ProvidePlugin定义一些别名:
new webpack.ProvidePlugin({
"jQuery": "jquery",
"$": "jquery",
"window.jQuery": "jquery"
})
关于javascript - Kendo UI 和 Vue.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37331508/