@@ -30,7 +30,26 @@ export default {
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 首次测量
|
||||
this.$nextTick(() => this.emitHeight())
|
||||
},
|
||||
watch: {
|
||||
// 国家列表变化 → 换行行数可能变化 → 重新测量
|
||||
'list.length'() {
|
||||
this.$nextTick(() => this.emitHeight())
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
emitHeight() {
|
||||
const query = uni.createSelectorQuery().in(this)
|
||||
query.select('#countryBar').boundingClientRect()
|
||||
query.exec((res) => {
|
||||
if (res && res[0]) {
|
||||
this.$emit('height-change', res[0].height)
|
||||
}
|
||||
})
|
||||
},
|
||||
selectItem(item) {
|
||||
this.$emit('select', item.id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user