Vue報錯(Property or method "xxx" is not defined on the instance but referenced during render.)

報錯如下:
Property or method “xxx” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
屬性或方法“xxx”不是在實例上定義的,而是在呈現期間引用的。通過初始化該屬性,確保該屬性是反應性的,無論是在data選項中,還是在基於類的組件中。

原因:
“xxx”在template或方法中使用了,但是沒有在data中定義

解決:

export default {
 data(){
  return{
    xxx:""
  }
 },
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章