Skip to content

Commit d7789e5

Browse files
committed
feat(index-list): support title slot
1 parent 5685c08 commit d7789e5

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/index-list/index-list.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
@pulling-down="onPullingDown"
1010
@pulling-up="onPullingUp">
1111
<div class="cube-index-list-content" ref="content">
12-
<h1 class="cube-index-list-title" v-if="title" ref="title" @click="titleClick">
13-
{{ title }}
12+
<h1 class="cube-index-list-title" v-if="hasTitle" ref="title" @click="titleClick">
13+
<slot name="title">{{ title }}</slot>
1414
</h1>
1515
<ul>
1616
<slot>
@@ -126,8 +126,11 @@
126126
}
127127
},
128128
computed: {
129+
hasTitle() {
130+
return this.title || this.$slots.title
131+
},
129132
fixedTitle() {
130-
this.title && !this.titleHeight && this._caculateTitleHeight()
133+
this.hasTitle && !this.titleHeight && this._caculateTitleHeight()
131134
132135
return this.scrollY <= -this.titleHeight && this.data[this.currentIndex] ? this.data[this.currentIndex].name : ''
133136
},
@@ -151,13 +154,14 @@
151154
},
152155
mounted() {
153156
this.$nextTick(() => {
154-
this.title && this._caculateTitleHeight()
155-
this._calculateHeight()
157+
this.refresh()
156158
})
157159
},
158160
methods: {
159161
/* TODO: remove refresh next minor version */
160162
refresh() {
163+
this._caculateTitleHeight()
164+
this._calculateHeight()
161165
this.$refs.scroll.refresh()
162166
},
163167
selectItem(item) {
@@ -238,8 +242,7 @@
238242
},
239243
title(newVal) {
240244
this.$nextTick(() => {
241-
this._caculateTitleHeight()
242-
this._calculateHeight()
245+
this.refresh()
243246
})
244247
},
245248
diff(newVal) {

0 commit comments

Comments
 (0)