首页底部
Test Runner / hello (push) Successful in 4s

This commit is contained in:
2026-08-25 18:12:16 +08:00
parent 69734f36b4
commit 4bee0101e7
22 changed files with 378 additions and 183 deletions
@@ -18,7 +18,33 @@ export default {
default: () => []
}
},
mounted() {
// 首次测量(可能为 0,因为 v-if 可能为 false
this.$nextTick(() => this.emitHeight())
},
watch: {
// 筛选标签增减 → 高度变化 → 重新测量
'list.length'() {
this.$nextTick(() => this.emitHeight())
}
},
methods: {
emitHeight() {
// v-if 为 false 时 #activeFilters 不存在,返回 0
if (!this.list || this.list.length === 0) {
this.$emit('height-change', 0)
return
}
const query = uni.createSelectorQuery().in(this)
query.select('#activeFilters').boundingClientRect()
query.exec((res) => {
if (res && res[0]) {
this.$emit('height-change', res[0].height)
} else {
this.$emit('height-change', 0)
}
})
},
onRemove(key) {
this.$emit('remove', key)
},
+19
View File
@@ -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)
}
+26
View File
@@ -81,7 +81,33 @@ export default {
// 商品滚动区固定高度(px),由父组件动态计算传入
scrollHeight: { type: Number, default: 400 }
},
mounted() {
// 首次测量子分类高度
this.$nextTick(() => this.emitSubHeight())
},
watch: {
// 子分类列表变化 → 重新测量
'subCategories.length'() {
this.$nextTick(() => this.emitSubHeight())
}
},
methods: {
emitSubHeight() {
// v-if 为 false 时 #subCategories 不存在,返回 0
if (!this.subCategories || this.subCategories.length === 0) {
this.$emit('sub-height-change', 0)
return
}
const query = uni.createSelectorQuery().in(this)
query.select('#subCategories').boundingClientRect()
query.exec((res) => {
if (res && res[0]) {
this.$emit('sub-height-change', res[0].height)
} else {
this.$emit('sub-height-change', 0)
}
})
},
selectSub(id) { this.$emit('sub-select', id) },
onTapProduct(item) { this.$emit('product-click', item) },
onScrollToLower() { this.$emit('scroll-to-lower') }
+13
View File
@@ -41,7 +41,20 @@ export default {
this.statusBarHeight = 20
}
},
mounted() {
// 测量自身高度并 emit 给父组件(小程序端无法跨组件查询 DOM,必须自测量)
this.$nextTick(() => this.emitHeight())
},
methods: {
emitHeight() {
const query = uni.createSelectorQuery().in(this)
query.select('#searchBar').boundingClientRect()
query.exec((res) => {
if (res && res[0]) {
this.$emit('height-change', res[0].height)
}
})
},
onInput(e) {
this.$emit('input', e.detail.value)
},