怎么在vue中引入bootstrap?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
一、引入jquery
步驟:
1. 安裝jquery
$ npm install jquery --save-dev
2.在webpack.config.js 添加內容
+ const webpack = require("webpack");
module.exports = {
entry: './index.js',
output: {
path: path.join(__dirname, './dist'),
publicPath: '/dist/',
filename: 'index.js'
},
+ plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery'
})
]
}3.在入口文件index.js 里面添加內容
import $ from 'jquery' ;
4.測試一下是否安裝成功,看看能否彈出'123'
<template>
<div>
Hello world!
</div>
</template>
<script>
$(function () {
alert(123);
});
export default {
};
</script>
<style>
</style>二、引入Bootstrap
1.安裝Bootstrap
$ npm install --save-dev bootstrap
2.在入口文件index.js里引入相關
import './node_modules/bootstrap/dist/css/bootstrap.min.css'; import './node_modules/bootstrap/dist/js/bootstrap.min.js';
3.添加一段Bootstrap代碼
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default">Left</button>
<button type="button" class="btn btn-default">Middle</button>
<button type="button" class="btn btn-default">Right</button>
</div>4.運行,查看效果這些按鈕已經變成Bootstrap按鈕組了。

關于怎么在vue中引入bootstrap問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。