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

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

      • 问题
      • 解决
      • props里定义属性,type属性有以下7种(注意:首字母要大写)

问题

Vue项目中遇到这样的问题,没有提示具体哪个文件出问题,定位起来比较麻烦,后面发现是组件里props对象定义的类型有问题
TypeError: Right-hand side of ‘instanceof’ is not callable
解决TypeError: Right-hand side of 'instanceof' is not callable_第1张图片

解决

错误的写法(写快了 没注意到)

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

改写为正确的写法

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

props里定义属性,type属性有以下7种(注意:首字母要大写)

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

props属性改正确之后,就解决了这个报错


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

你可能感兴趣的:(Vue)