반응형
다시 로드한 후 vue-temp가 잘못된 매개 변수를 설정함
있습니다
// routes.js
{ path: '/posts', name: 'Posts', component: PostsView },
{
path: '/post/:post_id',
name: 'PostRead',
component: PostReadView,
},
{
path: '/post/cu/:post_id?',
name: 'PostCreateUpdate',
component: PostCreateUpdateView,
},
// PostCreateUpdate.vue
mounted: function() {
if( this.$route.params.post_id ) {
this.$store.dispatch('getPost', this.$route.params.post_id);
}
},
다음과 같은 라우터 링크를 통해 PostCreateUpdate에 액세스할 때
<router-link :to="{ name: 'PostCreateUpdate' }">Create</router-link>
Vue Devtools의 매개 변수가 설정되지 않았지만 URL을 다시 로드하거나 하드 코딩하여 URL에 액세스할 때 문제가 없음/post/cu/
골격(내 생각에)은 후행 슬래시를 제거하고 치료한다.cu
일부로서/post/
매개변수, 따라서 로드PostRead
, 와 함께.post_id=cu
내가 원하지 않는 걸 주는 거야
당신은 항상 당신의 가장 제한적인 URI를 먼저 선언할 필요가 있다.주문은 중요한데, 왜냐하면 Vue Router는 당신의 경로를 거치게 될 것이고, 가장 먼저 일치하는 것을 고르시오.
뒤집기/post/:post_id
노선과/post/cu/:post_id?
원:
// routes.js
{ path: '/posts', name: 'Posts', component: PostsView },
{
path: '/post/cu/:post_id?',
name: 'PostCreateUpdate',
component: PostCreateUpdateView,
},
{
path: '/post/:post_id',
name: 'PostRead',
component: PostReadView,
},
참조URL: https://stackoverflow.com/questions/62734926/vue-router-sets-wrong-parameter-after-reloading
반응형
'IT이야기' 카테고리의 다른 글
vue-properties는 구성 요소를 렌더링하는 것이 아니라 이 구성 요소의 URL을 변경하는 것이다.1달러짜리밀다 (0) | 2022.03.22 |
---|---|
사전을 복사하고 사본만 편집하는 방법 (0) | 2022.03.22 |
UnicodeDecodeError: 'charmap' 코덱이 위치 Y: 문자 맵을 디코딩할 수 없음 (0) | 2022.03.21 |
왜 우리는 sys를 사용하지 말아야 하는가.py 스크립트에서 setdefaultencoding("utf-8")을 설정하시겠습니까? (0) | 2022.03.21 |
Vue.js의 사용자 지정 양식 구성 요소에 네이티브 입력 이벤트를 사용해야 하는가? (0) | 2022.03.21 |