vue 未登录时,访问其他页面会出现页面一闪而过

  • vueHook.js


import Cookies from 'js-cookie'
export default {
  beforeCreate: () => {
    const tyqxToken = Cookies.get('tyqxToken')
    const isLoginPage = location.href.indexOf('/login') !== -1
    if (!tyqxToken && !isLoginPage) {
      location.href = '/login'
    }
  }
}


  • main.js

import vueHook from '@_src/utils/vueHook.js'
 new Vue({
    router,
    store,
    ...vueHook,
    render: h => h(App)
  }).$mount('#app')

你可能感兴趣的:(vue 未登录时,访问其他页面会出现页面一闪而过)