vue 添加版本号

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
/**
 * 添加版本号
**/
  if (document.URL.indexOf('?t=') < 0) {
    let timestamp = (new Date()).valueOf()
    window.location.href = '?t=' + timestamp + '#' + to.fullPath
  }
  if (to.meta.requireAuth) {
    if (getStore('personal') && getStore("loginFlag") == 1) {
      next();
    } else {
      next({
        path: '/login',
        query: {redirect: to.fullPath}
      })
    }
  } else {
    next();
  }
});

你可能感兴趣的:(Vue)