The difference between watch and computer in vue, the problem of getting the value when the route is redirected.

The following tree directory is used in the

project, each using the same route at the same level, and rendering different pages according to the routing parameters.

in the tree directory, clicking on each node will commit the current node information to the currentNode of vuex. Now I update the current node information in the component to get the id; of node.
there is a problem that I can"t figure out:
is going to use

at the beginning.
    watch: {
         $route(val, newval){
          //URLnodeId
        }
    }

but watch works when you click on nodes at the same level to jump, but watch does not take effect when you click on nodes at different levels.

then use the computer calculation property in the component to obtain the id; in real time through the global node information of Vuex.

computed: {
        currentNode(){
            return this.$store.state.currentNode
        }
    }

excuse me, why is this?

Oct.13,2021
Menu