Skip to content

Commit

Permalink
feat: 搜索页面tab切换同步到路由
Browse files Browse the repository at this point in the history
  • Loading branch information
sl1673495 committed Aug 22, 2019
1 parent c19b01a commit cb00327
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default {
goSearch(keywords) {
this.searchHistorys.push({ first: keywords })
storage.set(SEARCH_HISTORY_KEY, this.searchHistorys)
this.$router.push(`/search/${keywords}`)
this.$router.push(`/search/songs/${keywords}`)
this.searchPanelShow = false
},
async onClickSong(item) {
Expand Down
9 changes: 7 additions & 2 deletions src/page/search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<div class="tabs-wrap">
<Tabs
:tabs="tabs"
@tabChange="onTabChange"
itemClass="search-tab-item"
v-model="activeTabIndex"
/>
Expand Down Expand Up @@ -57,15 +58,19 @@ export default {
data() {
return {
count: 0,
activeTabIndex: 0
activeTabIndex: tabs.findIndex(
({ key }) => key === this.$route.params.type
)
}
},
methods: {
onUpdateCount(count) {
this.count = count
},
onTabChange() {
this.$router.push(`/search/${this.currentTab.key}/${this.keywords}`)
}
},
computed: {
currentTab() {
return tabs[this.activeTabIndex]
Expand Down
2 changes: 1 addition & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default new Router({
component: PlaylistDetail,
},
{
path: '/search/:keywords',
path: '/search/:type/:keywords',
name: 'search',
component: Search,
props: true,
Expand Down

0 comments on commit cb00327

Please sign in to comment.