Vue问题整理

10/11/2018 Vue

# css中引用背景图片,在不打包成Base64的情况下路径错误

build/utils.js

// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
  return ExtractTextPlugin.extract({
    use: loaders,
    publicPath: '../../',         //solution: 注意配置这一部分,根据目录结构自由调整
    fallback: 'vue-style-loader'
  })
} else {
  return ['vue-style-loader'].concat(loaders)
}
1
2
3
4
5
6
7
8
9
10
11

# 兼容IE

npm i --save-dev babel-polyfill
将webpack.base.conf.js中的entry修改为:

entry: {
  app: ['babel-polyfill', './src/main.js']
},
1
2
3

# vue中使用bootstrap

1.npm install jquery --save-dev 引入jquery
2.在webpack.base.conf.js中添加如下内容:

const webpack = require('webpack')
1

// 增加一个plugins

plugins: [
  new webpack.ProvidePlugin({
    $: "jquery",
    jQuery: "jquery"
  })
],
1
2
3
4
5
6

3.在main.js中添加内容:

import $ from 'jquery'
1

4.安装bootstrap:

npm install bootstrap --save-dev  
1

5.在main.js下加入以下内容:

import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min'
1
2