vue注意事项

278 阅读1分钟

一、火狐浏览器兼容问题:必须加上$event,要不然单选框无效

    
    @click="clicks1($event);clicks4()">   

    clicks1($event){
        
    }
    

二、js引用图片加载不出来用变量

   import imgList from '../../assets/img/manufactorTitleImg.jpg'
  <img src="'+imgList+'" alt="imgList" width="603" height="300">

npm install echarts --save

roam:false 禁止拖拽缩放

三、设置当前页面背景颜色


beforeRouteEnter(to, from, next) {
    // 添加背景色
    document.querySelector('body').setAttribute('style', 'background-color:#f9f9f9')
    next()
},
beforeRouteLeave(to, from, next) {
    // 去除背景色
    document.querySelector('body').setAttribute('style', '')
    next()
}

四、白屏-es6转es5

npm install babel-polyfill
npm install es6-promise

//main.js

import 'babel-polyfill'
import Vue from 'vue'
import Es6Promise from 'es6-promise'
require('es6-promise').polyfill()
Es6Promise.polyfill()


module.exports = {
entry: {
    app: ['babel-polyfill', './src/main.js']
},
module: {
    rules: [{
            test: /\.vue$/,
            loader: 'vue-loader',
            options: vueLoaderConfig
        },
        {
            test: /\.js$/,
            loader: 'babel-loader',
            query:{presets:['es2015']},
            include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
        },