我爱编程

vue-cli 引入jq,bootstrap,swiper

2018-02-28  本文已影响0人  秃头大叔

引入jqeury方式

// 在webpack.base.config.js中的module.exports中添加配置,如下
plugins: [
  new webpack.optimize.CommonsChunkPlugin('common.js'),
  new webpack.ProvidePlugin({
  jQuery: "jquery",
  $: "jquery"
  })
]

引入bootstrap方式

// 通过npm安装bootstrap  npm i bootstrap
//在main.js 通过import引入
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap/dist/js/bootstrap.min.js'

引入swiper方式

// 在index.html中手动引入  <script src="./static/swiper.js"></script>
// 在webpack.base.config.js中的module.exports中添加配置,如下
externals:{
    swiper:'Swiper',
  },
//在main.js或需要的页面 通过import引入
import Swiper from swiper
上一篇 下一篇

猜你喜欢

热点阅读