vue ts 组件 @Prop 初始值设置无效 vue-property-decorator

时间:2020-08-11 16:08:39   收藏:0   阅读:563

使用 vue + ts ,进行编写组件时,发现以下代码

 

?错误写法,这样会导致,父组件引用使用 初始值设置 visible = true 不生效

@Component
export default class Pop extends Vue {
  @Prop({ type: Boolean, default: false }) readonly visible: boolean=false;
}

??正确使用方法

@Component
export default class Pop extends Vue {
  @Prop({ type: Boolean, default: false }) readonly visible!: boolean;
}

 

原文:https://www.cnblogs.com/richard1015/p/13476009.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!