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

使用 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