Skip to content

Commit

Permalink
调整点击跳转逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
pekonchan committed Apr 10, 2020
1 parent cca07fb commit 0ccade6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ export default {
/**
* 选择标题跳到对应内容
*/
selectNav (nav, index) {
async selectNav (nav, index) {
this.scrollContainer.scrollTop = this.offsetTops[`content${index}`] - this.scrollDeviation;
await this.$nextTick();
this.resetNavSelect();
nav.checked = true;
this.scrollContainer.scrollTop = this.offsetTops[`content${index}`] - this.scrollDeviation;
},
resetNavSelect () {
this.navMenu.forEach(item => {
Expand Down
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div class="content">导航1内容</div>
<div class="content">导航2内容</div>
<div class="content">导航3内容</div>
<div class="content">导航4内容</div>
</Scroll-Nav>
</div>
</template>
Expand All @@ -34,6 +35,9 @@ export default {
},
{
label: '导航3'
},
{
label: '导航4'
}
]
};
Expand Down

0 comments on commit 0ccade6

Please sign in to comment.