Typescript vue 3中的道具在类基组件中不可访问

Typescript vue 3中的道具在类基组件中不可访问,typescript,vue.js,Typescript,Vue.js,我正在迁移到vue 3。我无法在我的类中访问道具值,相反,它给我0,并且没有在控制台中打印我在道具上使用的最新值。在模板上,它运行良好,但我想在我的类中的titleComponent的最新值 从“Vue类组件”导入{Options,Vue}; @选择权({ 道具:{ 标题成分:编号 } }) 导出默认类StorePin扩展Vue{ 私有标题组件=0; 安装的() { console.log(this.propValue); } 获取propValue() { 返回此.titleComponent

我正在迁移到vue 3。我无法在我的类中访问道具值,相反,它给我0,并且没有在控制台中打印我在道具上使用的最新值。在模板上,它运行良好,但我想在我的类中的titleComponent的最新值

从“Vue类组件”导入{Options,Vue};
@选择权({
道具:{
标题成分:编号
}
})
导出默认类StorePin扩展Vue{
私有标题组件=0;
安装的()
{
console.log(this.propValue);
}
获取propValue()
{
返回此.titleComponent;
}
递增()
{
this.titleComponent++;
}
}

道具应该是只读的,因此如果您想修改组件中的
标题组件
,您需要修改本地副本(例如,来自观察者):

从“Vue类组件”导入{Options,Vue};
@选择权({
道具:{
标题成分:编号
},
观察:{
标题成分(val){
这是。_titleComponent=val;
}
}
})
导出默认类StorePin扩展Vue{
私有_titleComponent=0;
获取propValue()
{
返回此项。\标题组件;
}
增量()
{
这个._titleComponent++;
}
}