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

 

相关文章:

  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
相关资源
相似解决方案