vuejs / pinia

🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support
https://pinia.vuejs.org
MIT License
12.72k stars 996 forks source link

After entering the route, the first v-model binding value cannot be captured and updated. #2678

Closed mietl closed 1 month ago

mietl commented 1 month ago

Reproduction

https://codesandbox.io/p/live/e6de1200-2ca6-4ca2-87f9-bc45bbb2a5c6

Steps to reproduce the bug

  1. After entering the routing, after binding the input to v-model in component A

    1. In the component B setup function, modify the state in the pinia store
  2. Component A input cannot display the updated status.

Expected behavior

Component A Show the updated value.

Actual behavior

Component A still shows the value before the update.

Additional information

  1. If you change the order in their template, it can work correctly.
  2. In the template, it is correct to display the status in the pinia store.
posva commented 1 month ago

This will happen without pinia too. The workaround/fix: change the value within onMounted.

mietl commented 1 month ago

This will happen without pinia too. The workaround/fix: change the value within onMounted.

Thank you for your reply.