I have a component with an observer
props: { propShow: { required: true, type: Boolean } }, data() { return { show: this.propShow } }, watch: { propShow: { handler: (val, oldVal) => { this.show = val; } } }
When the parent propShow component propShow this component must update its show property. This component also modifies the show property, so I need both: show and propShow , because Vue.js does not allow you to directly change the properties.
This line
this.show = val;
causes an error
TypeError: Cannot set property 'show' of undefined
since This inside the handler is undefined .
Why?
source share