1、Vue引入BootStrap

建立Vue框架后

cnpm install jquery --save-dev


cnpm install style-loader --save-dev

cnpm install file-loader --save-dev

cnpm install css-loader --save-dev

在module.exports里面加上

const webpack=require("webpack")


plugins: [

newwebpack.ProvidePlugin({

$:"jquery",

jQuery:"jquery",

"windows.jQuery":"jquery"

    })

  ],


还是在module.exports里找到resolve,在alias后面加上:

jquery:"jquery/src/jquery"

在main.js入口文件添加

import $from 'jquery' ;

import '../node_modules/bootstrap/dist/css/bootstrap.min.css';

import '../node_modules/bootstrap/dist/js/bootstrap.min.js';

注意:JQuery的版本要调成与Bootstrap否则会有一些功能报错。另外Bootstrap4版本还需要引入popper.js,具体操作同JQuery。

你可能感兴趣的:(1、Vue引入BootStrap)