1、安裝jquery
npm install jquery --save
2、或則在package.json中指定版本號,然后運行npm install命令
"dependencies": {
"axios": "^0.18.0",
"core-js": "^2.6.5",
"jquery": "^3.4.1",
"vue": "^2.6.10",
"vue-awesome-swiper": "^3.1.3",
"vue-router": "^3.0.3",
"vuex": "^3.0.1"
},
3、在vue.config.js里面配置
const webpack = require('webpack');
const path = require('path');
// vue.config.js
module.exports = {
// 選項...
devServer: {
port: 8089,
// proxy:{
// '/': {
// target: 'http://192.168.0.125:3000/',
// changeOrigin: true,
// pathRewrite: {}
// },
// }
},
configureWebpack: {//引入jquery plugins: [ new webpack.ProvidePlugin({ $:"jquery", jQuery:"jquery", "windows.jQuery":"jquery" }) ] },
}
然后在頁面里就可以愉快的使用jquery了
npm install --save-dev bootstrap
在main.js中引入
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/js/bootstrap.min.js';
然后運行,結果按照提示讓執行這樣的命令
npm install --save popper.js
然后,再運行 就能成功使用bootstrap了