vue2.0報錯及問題解決

一、

TypeError:_self。$ scopedSlots.default不是renderCell的函數(shù)
(eval at(app.js:1425),:10386:45)

二、

Cannot read property xxx of undefined (
Cannot read property 'xxx' of null
Cannot read property 'focus' of undefined

  • 解釋:
    使用.xxx的那個對象為undefined
三、

解決 vue.js在火狐瀏覽器報錯 "event is not defined" 的問題

https://blog.csdn.net/u012317188/article/details/79031327

四、

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

https://www.cnblogs.com/zhn0823/p/6820605.html?utm_source=itdadao&utm_medium=referral

五、

Invalid default value for prop "value": Props with type Object/Array must use a factory function to return the default value

六、

vue項目報錯如下:(Emitted value instead of an instance of Error)

七、

Invalid prop: type check failed for prop "value". Expected String, Number, got Undefined.

  • 解釋:
    prop期待傳入數(shù)組,傳入的卻是字符串。類型錯誤

https://www.iphpt.com/detail/98/

八、

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

九、

npm install 報node-sass錯誤

十、

vue組件中 style報錯 Newline required at end of file but not found

十一、

vue使用jquery,警告 '$' is not defined

  • 解決辦法:修改根目錄下.eslintrc.js文件,在module.exports中,為env添加一個鍵值對 jquery: true
env: { 
  browser: true, 
  jquery: true // 添加 
} 

https://blog.csdn.net/qq_35430000/article/details/80960423

十二

vue中引入并且使用jquery,修復使用eslint時報 $、 jquery找不到的錯誤

https://blog.csdn.net/qq_35430000/article/details/80960423

十三、

移動vue項目,啟動錯誤:Module build failed: Error: No PostCSS Config found in:

https://blog.csdn.net/qq_26744901/article/details/80434684

十四、

You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file.

  • 解釋:你可以使用特殊注釋禁用某些警告。使用//eslint disable next line忽略下一行。使用/eslint disable/忽略文件中的所有警告?!?/li>
  • 解決辦法:
module: {
  rules: [
    //...(config.dev.useEslint ? [createLintingRule()] : []), // 注釋或者刪除
    {
      test: /\.vue$/,
      loader: 'vue-loader',
      options: vueLoaderConfig
    },
    ...
    }
  ]
}

https://www.cnblogs.com/gaoquanquan/p/9550169.html

十五、

Vue.js報錯"TypeError: Cannot read property 'name' of undefined"

https://blog.csdn.net/qq_41999617/article/details/86473650

十六、

Error in render: "TypeError: Cannot read property 'XXXXX' of undefined"

十七、

[Vue warn]: Error in event handler for "click": "TypeError: Cannot read property 'validate' of undefined"

  • 解決方法: this.$refs.form.validate()中的與ref="form"名字叫的不一致,或者沒有定義ref。

https://blog.csdn.net/qq_37495786/article/details/83692544

十八、

vue開發(fā)中v-for在Eslint的規(guī)則檢查下出現(xiàn):Elements in iteration expect to have 'v-bind:key' directives

  • 原因: VScode編輯器vue開發(fā)過程中,因為安裝了ESLint插件,對vue進行了eslint檢查,只需將這個規(guī)則檢查屏蔽掉即可

https://blog.csdn.net/jagger_guo/article/details/78942692

十九、

vue報錯Cannot read property 'addEventListener' of null"

  • 原因:獲取id元素的時候沒有獲取到,頁面中的這個id元素不是在dom加載完成之后動態(tài)添加上去的。

https://ask.csdn.net/questions/717925

二十、

element-ui 會報錯:Error: No PostCSS Config found in element-ui/lib/theme-chalk(多個項目復用node_modules,npm install 時報錯)

  • 解決辦法:(npm install 不會產(chǎn)生該文件,仍可能會發(fā)生報錯)
    element-ui/lib/theme-chalk里面創(chuàng)建了postcss.config.js文件,內(nèi)容為:
module.exports = {}

https://blog.csdn.net/weixin_43249693/article/details/84766441

  • 解決辦法(永久有效):
    根目錄下創(chuàng)建postcss.config.js文件,內(nèi)容為:
module.exports = { 
    plugins: { 
      'autoprefixer': {browsers: 'last 5 version'} 
    } 
  }

https://blog.csdn.net/jokren/article/details/86065217

二十一、

在圖片地址src不變的情況下,瀏覽器重新加載圖片失敗,圖片未刷新

  • 原因:在src不變時,瀏覽器直接就去讀取緩存
  • 解決辦法:在圖片路徑上拼接一個隨機數(shù),可以讀取到圖片路徑的變化,重新加載圖片
var img_src ='http://www.ilsea.net/images/seagull.jpg?t='+Math.random(); 

https://blog.csdn.net/maoxunxing/article/details/40618617

二十二、

setInterval只執(zhí)行一次

  • 解決辦法:
    setInterval(direct, 1000);//去掉括號就好

https://bbs.csdn.net/topics/392057623?page=1

二十三、

Vue.js報錯"TypeError: Cannot read property 'name' of undefined"
{{info.supports}}是不會報錯的,{{info.supports.name}}報錯

  • 原因:info.supports是undefined,undefined.name就報錯了
  • 解決辦法:v-if
    <span v-if="info.support">{{info.supports.name}}</span>

https://blog.csdn.net/qq_36742720/article/details/83627213

二十四、

Connection refused [tcp://127.0.0.1:6379]

  • 原因:6379默認是redis的端口,redis服務(wù)未啟動

https://blog.csdn.net/abcde158308/article/details/54380435?utm_source=blogxgwz3

二十五、

圖片未加載完成,圖片不顯示(本地的圖片)

  • 解決辦法:將圖片路徑定義為變量
<img :src="imgUrl">
     data(){
            return {
              imgUrl: require("@/assets/images/fk.jpg"); // 圖片路徑用 @
            }
        }

https://blog.csdn.net/qq_41387882/article/details/82690337?utm_source=blogxgwz3

二十六、20200727 新增

  • 解決1:

[vue-router] Duplicate named routes definition: { name: "home", path: "/home" }

  • 原因:vue 項目,路由為 / ,和 /home ,掛載的組件都是同一個,就會在控制臺報警告
{
      path: '/',
      redirect: {
        name: 'home'
      }
    },
    {
      path: '/home',
      name: 'home',
      component: home
    },

https://blog.csdn.net/weixin_34106122/article/details/88204390

  • 解決2:

[vue-router] Duplicate named routes definition: { name: "模板", path: "/exam/" }

二十七、

[Vue warn]: The data property "record" is already declared as a prop. Use prop default value instead.

  • 翻譯:數(shù)據(jù)屬性“record”已聲明為prop。 請改用prop默認值。即,子組件接收父組件值得時候已經(jīng)用了record這個key,但是在子組件的data里又定義了record,所以報錯
  • 解決:把 data 或 prop 中的record 換一個名字
    https://www.cnblogs.com/bobo1/p/11340710.html

二十八、

Navigating to current location (XXX) is not allowed

  • 原因:在路由中添加了相同的路由。
  • 解決:
    重寫路由的push方法
    在src/router/index.js 里面import Router from 'vue-router'下面寫入下面方法即可
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

https://www.cnblogs.com/lxk0301/p/11671256.html

二十九、

Error in v-on handler: "TypeError: _vm.shortDomain is not a function"

三十、

Duplicate keys detected: '0'. This may cause an update error.

三十一、js賦值后,改變現(xiàn)有數(shù)據(jù)會修改原來的數(shù)據(jù)

  • 數(shù)組A,去重后生成數(shù)組B,原數(shù)組A的值發(fā)生了改變
  • 對象賦值,清空后,原對象改變
    示例:let obj2 = { a: 1 }
    let obj = obj2
    obj = {}
    則 obj2 = {} (obj清空導致obj2清空)
  • 解決辦法:
    采用深拷貝的方法 :
let obj2 = JSON.parse(JSON.stringify(obj1))

https://www.cnblogs.com/guangzhou11/p/11498166.html

三十一、

vue.js:634 [Vue warn]: Unknown custom element: <CustomPageHeaderIndex> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

  • 報錯原因1:一個vue文件里寫了兩個
    components: {
    },
    解決辦法:刪除一個

  • 報錯原因2:組件引用,加了大括號
    import { CustomPageHeaderIndex } from '@/components/customPageHeader/index.vue';
    解決辦法:去掉括號
    import CustomPageHeaderIndex from '@/components/customPageHeader/index.vue';

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 第2章 基本語法 2.1 概述 基本句法和變量 語句 JavaScript程序的執(zhí)行單位為行(line),也就是一...
    悟名先生閱讀 4,613評論 0 13
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML標準。 注意:講述HT...
    kismetajun閱讀 28,878評論 1 45
  • 1、自制linux系統(tǒng) 開啟此虛擬機 2、/proc目錄和/sys目錄 /proc目錄:內(nèi)核把自己內(nèi)部狀態(tài)信息及統(tǒng)...
    阿喪小威閱讀 1,360評論 2 0
  • 如夢令 驚艷 文/付朝蘭 白衣少女背站 讓看長發(fā)披肩 不讓猜心愿 人們各猜其愿 驚艷 驚艷 美麗驚擾魚歡
    付朝蘭閱讀 892評論 20 18
  • 我家小寶5個半月了,隨著她一天天的長大,想著為她記錄下她成長過程中的一點一滴,便于她長大以后閱讀,于是就有了我這篇...
    11小蘑菇閱讀 796評論 5 0

友情鏈接更多精彩內(nèi)容