如何使用npm安装bootstrap

来源 | https://www.html.cn/web/javascript/20645.html
jquery安装
1、在package.json中添加一行代码:“jquery”: “^2.2.3”
"dependencies": {"element-ui": "^2.0.5","vue": "^2.5.2","vue-router": "^3.0.1","jquery": "^2.2.3"}
2、在build文件webpack.base.conf.js中添加一行数据:
//注:...代表省略自有的,//必定事先声明webpack,不然下面会不识别webpackconst webpack = require('webpack')...module.exports = {resolve: {...alias: {...'jquery': 'jquery'}},plugins: [new webpack.ProvidePlugin({$: "jquery",jQuery: "jquery","windows.jQuery": "jquery"})],...}
3、在main.js中加入:import $ from ‘jquery’
4、使用npm install jquery@2.2.3 –save-dev

这样jquery就安装完成了。
bootstrap安装:
1、使用npm install bootstrap@3.3.0 –save-dev

2、在需要的页面引入
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min.js'
最后npm run dev启动项目,就ok啦。

评论
