diff --git a/components-diy/diy-category-item.vue b/components-diy/diy-category-item.vue index edad688..ba37b3b 100644 --- a/components-diy/diy-category-item.vue +++ b/components-diy/diy-category-item.vue @@ -646,6 +646,9 @@ export default { } }, watch: { + oneCategoryHeight: function () { + this.$forceUpdate(); + }, oneCategorySelect: function () { this.scrollTop = -1; this.goodsList = []; diff --git a/components-diy/diy-category.vue b/components-diy/diy-category.vue index 4de861a..51aa627 100644 --- a/components-diy/diy-category.vue +++ b/components-diy/diy-category.vue @@ -537,20 +537,20 @@ export default { this.getOneCategoryItemHeight(index); }, getOneCategoryItemHeight(index) { - if (!query || typeof query.selectAll !== 'function') { - query = uni.createSelectorQuery && uni.createSelectorQuery().in(this); - } - if (!query || typeof query.selectAll !== 'function') { - return; - } - query - .selectAll('.category-item-wrap .category-item') - .boundingClientRect(data => { - if (data && data.length > index && data[index].height) { - this.oneCategoryItemHeight = data[index].height; - } - }) - .exec(); + setTimeout(() => { + const newQuery = uni.createSelectorQuery && uni.createSelectorQuery().in(this); + if (!newQuery || typeof newQuery.selectAll !== 'function') { + return; + } + newQuery + .selectAll('.category-item-wrap .category-item') + .boundingClientRect(data => { + if (data && data.length > index && data[index].height) { + this.oneCategoryItemHeight = data[index].height; + } + }) + .exec(); + }, 200); }, saveSecondCategoryName(name) { this.lastSecondCategoryName = name;