Vue webpack引入bootstarp
参考
安装
-
执行指令 npm install jquery --save-dev
-
打开项目build目录,向webpack.base.conf.js头添加内容
const webpack = require(‘webpack’)
-
向module.exports 添加插件
plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", jquery: "jquery", "window.jQuery": "jquery" })
],
-
向main.js 添加 import $ from ‘jquery’
-
启动项目测试看jQuery是否引入,会报错 ‘$’ is defined but never used
翻译意思是 已经被定义,但是未被使用
解决:
1. 使用jquery
2. .eslintrc.js文件 rules添加规则: “no-unused-vars”: ‘off’
-
安装bootstrap: npm install bootstrap --save-dev
-
mian.js引入bootstrap
import 'bootstrap/dist/css/bootstrap.min.css' import 'bootstrap/dist/js/bootstrap.min.js'