IT이야기

앞에 매개 변수를 추가하는 방법각

cyworld 2022. 3. 16. 22:04
반응형

앞에 매개 변수를 추가하는 방법각

router.beforeEach((to, from, next) => {
  if (auth) {
    next()
  } else {
    next('/')
  }
})

사용.vue-router beforeEach통제를 하다auth, 만약 성공한다면.true가다next그렇지 않으면 로 리디렉션된다.'/'잘 되긴 하지만 집으로 돌아가면 좋겠어'/'로그인 대화 상자를 팝업하십시오.

그래서 나는 이렇게 바꾼다.

next({path: '/', params: { showLogin: true }})

내가 설정했을 때auth거짓으로, 내 생각에는.home.vue,console.log(this.$route.params.showLogin)주다undefined

참조URL: https://stackoverflow.com/questions/48702714/how-to-add-parameter-in-beforeeach

반응형