如何使用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中添加一行數(shù)據(jù):
//注:...代表省略自有的,//必定事先聲明webpack,不然下面會(huì)不識別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 [email protected] –save-dev

這樣jquery就安裝完成了。
bootstrap安裝:
1、使用npm install [email protected] –save-dev

2、在需要的頁面引入
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min.js'
最后npm run dev啟動(dòng)項(xiàng)目,就ok啦。

評論
圖片
表情
