Comments (3)
The reason is that the computed get
only updates on the next tick, after the parent has received the value, and re-rendered.
So value.value.push(2)
updates the old, empty array
I see how that can be counter-intuitive, but it's working as expected, from a technical perspective.
Solution: first, manipulate you array, then, assign the final result to the computed to trigger the emit.
from core.
They have different results because only in the second example so you add a new array. In the first example, you manipulate the original array.
from core.
The reason is that the computed
get
only updates on the next tick, after the parent has received the value, and re-rendered. Sovalue.value.push(2)
updates the old, empty arrayI see how that can be counter-intuitive, but it's working as expected, from a technical perspective.
Solution: first, manipulate you array, then, assign the final result to the computed to trigger the emit.
Thank you for your quick response!
Did I understand correctly that this behaviour only works when using array methods along with assignment?
An example
value.value.push(1);
value.value.push(2);
and
value.value = [1];
value.value.push(2);
have different results
from core.
Related Issues (20)
- Inconsistency order of `created` hook between component and custom directive HOT 1
- V-show isn't working on an element with a style attribute HOT 1
- vue 3.4.18 (since 3.4.16) with vite 5.1.1 and rollup-typescript-plugin2 (ui-kit) build error HOT 3
- (v-model): v-model setter function not working properly when returning a constant value HOT 1
- The default value of defineModel is not ssr friendly HOT 1
- Hydration style mismatch HOT 1
- mismatched child nodes count in `patchBlockChildren` when rendering component returning render function in JSX from `computed()` with `<slot v-if="ref">` HOT 1
- Custom Web Elements/Components receive `null` instead of `false` on subsequent re-render HOT 2
- Execution of click event in v-for area in combination with change of outer ref triggers re-rendering of whole list HOT 3
- Vue compiler adds import of mergeModels from vue, while it is not exposed in typings. HOT 5
- Facebook Appeal link not working
- Hydration errors style attribute since vue 3.4 HOT 4
- Nested v-show ignores 'outer' value, and component with v-show="false" is shown. HOT 3
- [Vue warn] Computed is still dirty after getter evaluation HOT 22
- Serverless function not installing dependencies HOT 1
- Script Setup Does Not Populate Name Property HOT 2
- defineModel value de-synchronizes between parent and child if @update handler is not provided HOT 3
- style is not cleared HOT 3
- css v-bind can't work in vue-cli HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.