vue2.0推荐使用的ui框架是element ui, 有人说使用vue跟element了,根本没有必要使用jquery与bootstrap了,这不太准确,elementui是后端管理系统的ui,而bootstrap是前端页面的ui,各有千秋!
直接上干货,vue架子搭建起来之后,直接执行
1:cnpm install jquery@2.1.1 --save cnpm i bootstrap@3.2.0 --save
2:找到webpack.config.js文件在module.exports里面添加
plugins: [
new webpack.ProvidePlugin({
$: “jquery”,
jQuery: “jquery”,
jquery: “jquery”,
“window.jQuery”: “jquery”
})
]
3:找到main.js导入相应的文件
import $ from ‘jquery’
import ‘bootstrap/dist/js/bootstrap.min.js’
import ‘bootstrap/dist/css/bootstrap.css’
这三个顺序不能改变
4:务必重新启动才能生效
npm run dev