After created, commit changes the state value, but can not get the first state value of the change.

requirements description

The directory structure of the

Header and Management components is shown below. There is a select element in the Header.vue file, and the value of select is obtained dynamically from the background. After getting the projectList, change the commit (projectId) to vuex, to change the default state.selectedProjectInfo.projectId value in the vuex, and then the Management.vue file gets the first projectId. that has just been loaded. As the selection of the select drop-down list continues to change to get the corresponding projectId

problem description

the commit sent to vuex after the hook function created brings the first projectId to vuex, but the Management file still gets the initial value of state.selectedProjectInfo.projectId set by vuex. After Header triggers the change event, Management can get the correct corresponding projectId.

to sum up: the sibling component Management file cannot correctly get the first changed state value of the Header component!

directory structure

  

						
Mar.31,2021

the value of the asynchronous request is obtained after the Management created, so it will appear as the console output 0

as you said.
Menu