import Vue from 'vue' import App from './App.vue' import router from './router' new Vue({ el: '#app', render: h => h(App), router })
當使用eslint校驗運行上面這段代碼時(該代碼在src/main.js文件中),會報錯javascript
✘ http://eslint.org/docs/rules/no-new Do not use 'new' for side effects html
src/main.js:8:1vue
new Vue({java
兩種方法解決該問題:app
方法一:定義一個變量xxx(可爲任意值)接收新建立的Vueide
let xxx = new Vue({ el: '#app', render: h => h(App), router }) Vue.use({ xxx })
方法二:在new Vue的上方添加一行注視,讓eslint不檢查"no-new"eslint
import Vue from 'vue' import App from './App.vue' import router from './router' /* eslint-disable no-new */ new Vue({ el: '#app', render: h => h(App), router })
參考博客及評論router
https://www.cnblogs.com/xzma/p/7727412.htmlhtm