如何在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按鈕組了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM