解决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属性改正确之后,就解决了这个报错


谢谢你阅读到了最后
期待你,点赞、评论、交流

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