composition-api: fix: [Vue warn]: Write operation failed: computed value is readonly.
đ The bug
At the moment, if a component that calls useFetch has a computed property returned from setup, it will give the following error:
[Vue warn]: Computed property was assigned to but it has no setter.
It still works correctly, but this is unattractive, and ideally we wouldnât be attempting to assign a value to a computed property at all.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 14
- Comments: 23 (5 by maintainers)
@chovyprognos In the composition API you would do that like so:
Iâm getting this same warning but itâs not even a computed variable.
later :
Setting page.contentâs value throws the warning about write operation. Is there any way to avoid this weird warning?
@davaipoka Hm, youâre right. I had a computed that depended on two values (say
countriesanduser addresses). The client-side render worked but the server-side didnât work (computed value was not pre-populated). When I added the dependencies the computed relies on -countriesanduser addressesrefs to the setup functionâs return object, the server-side render started working.Normally I wouldnât include those 2 refs in the return object - theyâre not used in the template. But if it makes it work it makes it work.
just because this is the top search result for this error. i ran into this issue when i accidentally had a
refattribute in my template that was named the same as a computed property. renaming/removing thereffixed things up for me.Iâll make sure to make an issue with a reproduction!
see https://github.com/vuejs/composition-api/issues/445