vue入門(一)----工程vue_sell

1.利用vue腳手架工具建立vue,webpack工程目錄

npm install -g vue-cli  安裝vue腳手架css

vue init webpack sell 初始化一個webpack模板,工程名是sell的項目html

cd sell 進入項目vue

npm install 安裝項目package.json配置文件中須要的依賴包java

npm run devnode

 2.vue入口html--index.html;js---main.js

在vue的初始階段,遇到的一些問題

(1)
報錯:ESLint: Do not use 'new' for side effects. (no-new) ESLink是檢查代碼一致性和錯誤的工具,解決以上報錯能夠修改ESLink配置,或者解決:解決:
解決: 1,添加/* eslint-disable no-new */註釋,ESLink會繞過檢查
2,使用let將new後的實例給一個變量,符合檢查,再也不報錯‘

(2)

 報錯You are running Vue in development mode.Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.htmlwebpack

 解決:Vue.config.productionTip = truegit


(3)
報錯:Do not mount Vue to <html> or <body> - mount to normal elements instead.

解決:new實例的vue對象,el的dom節點會被template模板替換,因此當節點是body or html時候,會發生報錯(可認爲html,body是dom不可少的節點,,so...)

(4)
報錯:Unhandled rejection RangeError: Maximum call stack size exceededill install loadIdealTree
解決:npm版本兼容問題,要不降版本,本媛以爲麻煩,直接cnpm install搞定

(5)
報錯:!!vue-stylus-loader!css-loader?{"sourceMap":true}!../node_modules/_vue-loade....
解決:great solution:https://github.com/vuejs/vue-loader/issues/415

(6)
報錯:關於eslink檢查的報錯
解決:自定義eslink檢查規則,例如強制分號的檢查等

(7)
報錯:
Cannot find module 'stylus'
解決:依賴中缺乏stylus的引入,在package中添加style-stylus,stylus,執行npm install;
Cannot find module ...之類的問題可同類解決

(8)
報錯:router.map is not a function
解決:vue2.0兼容問題,router的map方法,只支持vue1.0版本
1.下降vue版本(不可取)
   2.兼容2.0版本寫法

(9)
報錯:router.start is not a function
解決:vue2.0兼容問題,該方法在2.0已經棄用

(10)
報錯:Failed to resolve directive: link
解決:
vue2.0兼容問題,v-link方法在2.0已經棄用,使用router-link

(11)
報錯:Unknown custom element: <route-view> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
解決:搜了好多東西,確認vue引入,組件已經註冊,浪費了好多時間,so...route-view寫錯,哎.......論避免低級的錯誤如何主要

(12)
報錯:當報錯解決以後,發現router-view沒有顯示,查看元素沒有渲染dom
解決:new Router({})中,實例化目標格式錯誤,routes Not routers


(13)
報錯: 路徑的引入容易致使錯誤,咱們能夠經過定義路徑別名解決
相關文章
相關標籤/搜索