解決TypeError: Right-hand side of 'instanceof' is not callable

解決TypeError: Right-hand side of 'instanceof' is not callable

問題

Vue項目中遇到這樣的問題,沒有提示具體哪個文件出問題,定位起來比較麻煩,後面發現是組件裏props對象定義的類型有問題
TypeError: Right-hand side of ‘instanceof’ is not callable
在這裏插入圖片描述

解決

錯誤的寫法(寫快了 沒注意到)

  props: {
    list: {
      type: {
        type: Array,
        default: () => {
          return []
        }
      }
    }
  }

改寫爲正確的寫法

  props: {
    list: {
      type: Array,
      default: () => {
        return []
      }
    }
  }

props裏定義屬性,type屬性有以下7種(注意:首字母要大寫)

  • String
  • Number
  • Function
  • Boolean
  • Object
  • Array
  • Symbol

props屬性改正確之後,就解決了這個報錯


謝謝你閱讀到了最後
期待你,點贊、評論、交流

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章