Skip to content

Commit e60ee69

Browse files
committed
feat(scroll-nav): support dynamic label & title
1 parent ea6878c commit e60ee69

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/components/scroll-nav/scroll-nav.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@
8181
return {
8282
scrollEvents: ['scroll', 'scroll-end'],
8383
scrollY: 0,
84-
labels: [],
85-
barTxts: [],
84+
panels: [],
8685
active: this.current,
8786
pageStickyOffset: 0
8887
}
8988
},
9089
computed: {
90+
labels() {
91+
return this.panels.map((panel) => panel.label)
92+
},
93+
barTxts() {
94+
return this.panels.map((panel) => panel.title)
95+
},
9196
barDirection() {
9297
return this.side ? DIRECTION_V : DIRECTION_H
9398
}
@@ -104,7 +109,6 @@
104109
},
105110
created() {
106111
this.navBar = null
107-
this.panels = []
108112
this.stickyCurrent = this.current
109113
},
110114
mounted() {
@@ -189,14 +193,10 @@
189193
},
190194
addPanel(panel) {
191195
this.panels.push(panel)
192-
this.labels.push(panel.label)
193-
this.barTxts.push(panel.title)
194196
},
195197
removePanel(panel) {
196198
const i = this.panels.indexOf(panel)
197199
this.panels.splice(i, 1)
198-
this.labels.splice(i, 1)
199-
this.barTxts.splice(i, 1)
200200
}
201201
},
202202
components: {

0 commit comments

Comments
 (0)