1.安裝插件
npm install jquery --save npm install bootstrap --save npm install popper.js --save
2.配置webpack.base.conf.js
//在頂部添加 const webpack = require('webpack') //在module.exports = {}末尾添加下面代碼 module.exports = { ... plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) ] }
3.在main.js中導入
import $ from 'jquery' import 'bootstrap' import 'bootstrap/dist/css/bootstrap.min.css' import 'bootstrap/dist/js/bootstrap.min'
4.測試jquery
//在vue文件中添加測試代碼 <script> $(function () { alert('jquery!') }) export default { name: 'App' } </script>
5.測試bootstrap
<button type="button" class="btn btn-success">bootstrap測試</button>
