JS uses the and or operator, and an error is reported: uncaught rangeerror: maximum call stack size exceeded

The or operator is used when the routing guard of the Vue item is in progress,

router.beforeEach((to,from,next) => {
  store.commit('cookie/getToken')
  let token = store.state.cookie.token
  if(!token && to.name === 'PersonalHome'||'Edit'||'EditBlog'||'EditDraft') {
      next('login')
  } else {
      next()
  }
})

Browser error:


solution:
wrap or calculate with ()

if(!token && to.name === ('PersonalHome'||'Edit'||'EditBlog'||'EditDraft')) {
      next('login')
  } else {
      next()
  }


Read More: