Solution for watch monitoring not taking effect for the first time in Vue

You can use the immediate method when you can’t listen for the first time, and its value is true or false; immediate: true means that if it is declared in wacth, the handler method inside will be executed immediately

watch: {

    'currentNavigation.param': {

      immediate: true,   //

      deep: true,

      handler (val, oldVal) {

        if (!Utils.isEmptyData(val) && oldVal !== val) {

          this.handleRouteParam() // Handle the page rendering data after the routing jump

        }

      }

    }

}

Guess you like

Origin blog.csdn.net/and_life/article/details/130615237