diff --git a/packages/src/index.vue b/packages/src/index.vue index 32cb94b..7a4ee3c 100644 --- a/packages/src/index.vue +++ b/packages/src/index.vue @@ -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 => { diff --git a/src/App.vue b/src/App.vue index 0334b0c..8bebea0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,6 +10,7 @@
导航1内容
导航2内容
导航3内容
+
导航4内容
@@ -34,6 +35,9 @@ export default { }, { label: '导航3' + }, + { + label: '导航4' } ] };