@Prop doesn't work on Vue2.7
gavinwyf opened this issue · 4 comments
@Prop({
type: Object,
default: () => ({
a: true,
b: false,
c: false,
}),
})
readonly aaa!: any;
localA = this.aaa;
created() {
this.localA.a = xxx;
}
[Vue warn]: Error in created hook: "TypeError: Cannot set properties of undefined (setting 'a')"
TypeError: Cannot set properties of undefined (setting 'a')
[Vue warn]: Property or method "formData" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
Desktop
OS: MacOS Monterey 12.4
Browser: Chrome 103.0.5060.114
Additional context
"vue": "^2.7",
"vue-class-component": "^7.2.2",
"vue-property-decorator": "^8.3.0",
May I ask how to solve this problem?
I'm facing this problem with vite, too. Let me know how to solve it.
Try using $props
. You may lose typing inference thought