webpack+bootstrap+vue 悠悠 2022-05-31 02:57 184阅读 0赞 vue-cli+webpack在生成的项目中使用bootstrap方法 脚手架生成项目 执行命令用webpack模板生成一个名为vuestrap的项目(名字任意) vue init webpack vue-boot 安装依赖 yarn install && yarn install jquery bootstrap –save 注:如果想查看npm上jquery有哪些版本,可以执行命令: npm view jquery versions 在build/webpack.dev.conf.js文件中,在整个配置对象的末尾增加plugins配置。 const webpack = require('webpack') plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "windows.jQuery": "jquery" }) ] 上面文章参考 [白色的海的博客][Link 1] jQuery的配置方法,网上也有人这么说[https://segmentfault.com/a/1190000006887523\#articleHeader3][https_segmentfault.com_a_1190000006887523_articleHeader3] ==================================== == 如果是bootstrap4.0 则需要另外安装 popper.js@1.12.9 ============= =================== 在此过程中遇到的错误 安装依赖的时候出现的错误 不知道什么问题,没办法用npm安装,我改成yarn安装解决了 $ npm install npm ERR! Unexpected end of JSON input while parsing near '...bd66185a2b79f2321a930' npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-02-05T07_48_17_904Z-debug.log 运行项目的时候出现的问题—–我的做法是删除所有依赖重新下载解决 $ npm run dev > vue-boot@1.0.0 dev C:\Users\Administrator\Desktop\react\vue-project\vue-boot > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js 'webpack-dev-server' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒ ▒▒▒▒▒▒▒▒▒ļ▒▒▒ npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vue-boot@1.0.0 dev: `webpack-dev-server --inline --progress --config bu ild/webpack.dev.conf.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vue-boot@1.0.0 dev script. npm ERR! This is probably not a problem with npm. There is likely additional log ging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-02-05T0 7_41_13_167Z-debug.log [Link 1]: https://www.cnblogs.com/kongxianghai/p/6910133.html [https_segmentfault.com_a_1190000006887523_articleHeader3]: https://segmentfault.com/a/1190000006887523#articleHeader3
还没有评论,来说两句吧...