Luc*_*950 7 typescript vue.js vue-router vuejs3
每次我在代码中使用“this”关键字时,它都会突出显示并表示“对象可能未定义”
当您将数据属性定义为箭头函数时,您应该this
作为参数传递,如下所示:
data:(vm)=>{//vm represents this keyword
return{
....
productType:vm.$route.path.slice(1).split("/")[0]
}
}
Run Code Online (Sandbox Code Playgroud)