VUE Custom Command F5 Failed to resolve directive after Refresh

VUE custom command F5 will report to Failed to resolve directive:auth, after refreshing
the function I want to achieve is to obtain permissions after login, and then use the custom command to control whether the button is displayed. The code is as follows:

 store.commit(types.RIGHT,  res.body.myRight)
            console.log(store.state.rights)
            Vue.directive("auth",{
                bind:function (el,binding) {
                  var isExist = false;
                  store.state.rights.forEach(function (item) {
                    if (item===binding.value) {
                      isExist =true
                    }
                  })
                  if (!isExist) {
                    el.parentNode.removeChild(el);
                  }
                },
              update:function (el,binding) {
                var isExist = false;
                store.state.rights.forEach(function (item) {
                  if (item===binding.value) {
                    isExist =true
                  }
                })
                if (!isExist) {
                  el.parentNode.removeChild(el);
                }
              }
              }

            )

this code exists after a successful login. Why do you have this problem every time you refresh the page with F5? I added UPDATE, but it"s useless. Still, there is a problem after refreshing. Ask God to answer it.

Mar.28,2021

after you refresh, the whole vue is reinitialized, and your login status no longer exists. You can use session, or vue to save your login status with localStorage. Every time you initialize vue, look for the login status in session or localStorage first, and then log in automatically.

Menu