vue-cli已经安装过
然后直接安装vue init webpack myProjectName
然后各种回车写入各种信息
然后引入elementui 命令是 npm install element-ui --save
然后启动其他开始引入其他数据
npm install jquery --save
npm install bootstrap --save
npm install popper.js --save
安装完成以后在 packagjson中查看
"dependencies": {
"bootstrap": "^4.3.1",
"element-ui": "^2.7.2",
"jquery": "^3.4.0",
"popper.js": "^1.15.0",
"vue": "^2.5.2",
"vue-router": "^3.0.1"
},
其中已经有了bootstrap jquery popper依赖
配置webpack.base.conf.js
顶部加入
const webpack = require('webpack')
然后在module.exports = {
…最下边加入
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
]
然后就是main.js中的配置
import $ from 'jquery'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min'
Vue.use($)
项目初始App.vue中修改如下
<template>
<div id="app">
<template>
<div>
<div class="row">
<div class="col-md-6">
<button class="btn btn-danger">测试按钮</button>
</div>
</div>
</div>
</template>
</div>
</template>
<script>
import $ from 'jquery'
$(function () {
alert('234')
})
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
项目启动效果如下