vue-Uncaught TypeError: Right-hand side of 'instanceof' is not an object

Uncaught TypeError: Right-hand side of 'instanceof' is not an object

at assertType (vue.esm.js?efeb:1668)

at assertProp (vue.esm.js?efeb:1626)

at validateProp (vue.esm.js?efeb:1560)

at loop (vue.esm.js?efeb:3334)

at initProps (vue.esm.js?efeb:3367)

at initState (vue.esm.js?efeb:3308)

at VueComponent.Vue._init (vue.esm.js?efeb:4628)

at new VueComponent (vue.esm.js?efeb:4798)

at createComponentInstanceForVnode (vue.esm.js?efeb:4310)

at init (vue.esm.js?efeb:4131)

 

原有的写法:

export default{
  props: {
    age: 3,
  }
}

修改后的写法:

export default{
  props: {
    age: {
       type: Number,
       default: 3,
    }
  },
 watch:{
age(){
console.info("age change")
}
  }
}

问题原因:

在vue中我们要定义相应的数据类型,这样在props中或者写watch方法监听的时候才能够被识别到。

你可能感兴趣的:(IT,vue)