반응형
vue 경로의 Bootstrap-vue 탭에서 특정 탭으로 이동하는 방법은 무엇입니까?
Bootstrap-vue 탭을 사용하고 있습니다.탭용 HTML:
<b-tabs>
<b-tab title="Exotic Dogs" href="#dogs">
<br>Dogs here
</b-tab>
<b-tab title="Exotic Cats" href="#cats">
<br>Cats here
</b-tab>
</b-tabs>
고양이를 위한 경로는 다음과 같습니다.
{
path: '/animals/:id#cats',
name: 'getCats',
component: Animals // removed from HTML to simplify
},
컴포넌트 코드:
this.$router.replace({ name: 'getCats', params: { id: this.$route.params.id }})
여기에는 다음이 필요합니다.
localhost: 3000/cats/234909888#cats
그러나 고양이 탭 대신 개 탭(첫 번째 탭)이 열려 있습니다.또한 브라우저를 새로 고치면 공백 페이지가 표시됩니다.
이 문제를 해결하려면 어떻게 해야 합니까?
추가해 볼 수 있습니다.v-model="tabIndex"
에게<b-tabs>
태그 부착 및 사용$route.hash
끼워 넣다mounted()
.
<b-tabs v-model="tabIndex">
<b-tab title="Exotic Dogs" href="#dogs">
<br>Dogs here
</b-tab>
<b-tab title="Exotic Cats" href="#cats">
<br>Cats here
</b-tab>
</b-tabs>
export default {
...
data() {
return {
tabIndex: 0,
tabs: ['#dogs', '#cats']
}
},
mounted() {
this.tabIndex = this.tabs.findIndex(tab => tab === this.$route.hash)
}
...
}
언급URL : https://stackoverflow.com/questions/52090371/how-to-navigate-to-specific-tab-in-bootstrap-vue-tabs-in-vue-routes
반응형
'programing' 카테고리의 다른 글
Vuej는 클래스를 행에 바인드한 후 나중에 행을 숨기거나 표시합니까? (0) | 2022.07.30 |
---|---|
Java에서 예외가 성능에 미치는 영향은 무엇입니까? (0) | 2022.07.30 |
인스턴스화 시 Vue 인스턴스가 마운트되지 않음 (0) | 2022.07.30 |
정의를 항상 괄호 안에 C로 둘러싸야 하는 타당한 이유가 있습니까? (0) | 2022.07.30 |
TypeError: 정의되지 않은 속성 'rtl'을 읽을 수 없습니다. (0) | 2022.07.30 |