-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modelValue
doesn't update value by Array.push
if using assigning
#10318
Comments
The reason is that the computed 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. |
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 |
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. |
Vue version
3.4.18
Link to minimal reproduction
https://play.vuejs.org/#eNqNVMtu2kAU/ZWRNzgSeETpoqIGkUYs2kUbtVU3OAvHvsAknofmQags/3vvjG1wSNJ25/s495z78NTRtVLJwUE0j1JTaKYsMWCdWmaCcSW1JTXRsCUN2WrJyQhTR6fQjeSq8yfUG77S6GMmMlFIYSzhZkcWHh9v7q7Qn9KWA6ujYYGrKreAFiFpKHaYcFlCtcgihGYRoRhL6SAxGkct+YTnKnkwUqDy2hfIuoDJojkJHu9DQd7Oor21yswpLUqBMORgB50IsFQoTleYRrUTlnGYlJKvZsn7ZPqBlszYoT8Bwyf3Wj4Z0Fgli8YDHorOA+iJBlGCBv2/vBewZ9wXsRf8nr7JRINjsQZnvmW7i6EUOFZWgf6mLMOdPBtOXlXy6UvwWe3g1Eyxh+LxFf+DObZN3WoIygYDsLnegW3D6x9f4YjfpyAu1VXdIt4IfgcjK+c1tmmfnChR9iAvqP0cdszE7qdZHy0I0zflhYZphPywEH9Rb7V+ljtLZoMp9lf8t//Bj9RZKC9+iv7olZbK4NmXsGUCbr0V1yTc9a+8cjAn11rnv0lz1SOAM3sCrNEw8WbkVIknPz/jRuEXahEH70BILyUOjWFH8VXXo0bVWrRiknMRrNDPCPuKQ50eEnTErxCPWz5P34KbsxIpbipWPKIWpF4s21IhPelFbqZ3ATnwJsqZffzOl2n+8S7sp8u67hpumpSiHfz3zlopyKrw9PhgdEKyaBnON6VtwosHpPkDw/Ov3g==
Steps to reproduce
Click on button
check
What is expected?
Displays an array with the value
[1,2]
What is actually happening?
Displays an array with the value
[1]
System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: