How to get state in real time in vue?

The

array is stored in state, and the page needs to be updated in real time as it changes.
the official document uses the calculation attribute computed. I usually pass it directly in the parent component and get it with props, so that when the state changes, it can directly affect the current component.
is there any difference between the two ways?

May.30,2022

the difference is that the data is changed in a different way.
parent and child components use emit
computed in the vuex way


if you need the value of this array after some calculation, use computed
for example, you want to filter map reduce the array passed in by prop or calculate it with other state and props to get its return value and then act on the current component

if you don't need the calculated array values, you can just take advantage of this prop

Menu