When vue uses the computed property to calculate certain values, when reassigning the value on the page, the error Computed property “xxxx” was assigned to but it has no setter is reported. Translated into Chinese, it means “calculated property “xxxx” has been assigned, but it has no setter. “, understand, that the attribute xxxx gets the value, but there is no way to set the value. Post the error code example:
computed: { cityOptions () { return this .$store.state.common.cityOptions } }, created () { this .getCityOptions() }, methods : { getCityOptions () { getCitys().then( res => { this .cityOptions = res.data }) } }
At this point, our code needs to be modified to:
computed: { cityOptions: { get () { return this .$store.state.common.cityOptions }, set ( val ) { return val } } }, created() { this .getCityOptions() }, methods: { getCityOptions() { getCitys().then(res => { this .cityOptions = res. data }) } }
Similar Posts:
- [Solved] Computed property “xxxx” was assigned to but it has no setter
- Solve the problem of “typeerror: ‘bool’ object is not callable” in flash and Django
- Vue3’s use of reactive/torefs + V-model leads to the failure of response and the failure of El form input
- WPF TextBox Placeholder
- How to deal with the error “cannot read property ‘set state’ of undefined” in react
- error: permission denied to create database [How to Solve]
- [Solved] Vue Axios error: TypeError: Cannot set property ‘tableData‘ of undefined
- [Solved] VueX Error: Cannot read property ‘commit’ of undefined
- El Form Verification Error: [XXX] is not a string [How to Solve]
- The solution to the error reported by MVC swagger.