From 068b6176f2ce37f60894c17ff11359ba5059091b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AB=E5=AE=9D=E7=B2=A5?= Date: Tue, 6 Dec 2022 17:53:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(u-dropdown):=20=F0=9F=90=9E=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dsticky=E5=B8=83=E5=B1=80=E6=97=B6=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=BB=9A=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对代码其他部分无修改,仅更改设置contentHeight的时机 #608 --- uview-ui/components/u-dropdown/u-dropdown.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uview-ui/components/u-dropdown/u-dropdown.vue b/uview-ui/components/u-dropdown/u-dropdown.vue index a62e469a..f3c5cf70 100644 --- a/uview-ui/components/u-dropdown/u-dropdown.vue +++ b/uview-ui/components/u-dropdown/u-dropdown.vue @@ -143,9 +143,7 @@ // 引用所有子组件(u-dropdown-item)的this,不能在data中声明变量,否则在微信小程序会造成循环引用而报错 this.children = []; }, - mounted() { - this.getContentHeight(); - }, + methods: { init() { // 当某个子组件内容变化时,触发父组件的init,父组件再让每一个子组件重新初始化一遍 @@ -172,6 +170,8 @@ }, // 打开下拉菜单 open(index) { + // 打开后才设置内容高度,以修复issue # 608 + this.getContentHeight() // 重置高亮索引,否则会造成多个菜单同时高亮 // this.highlightIndex = 9999; // 展开时,设置下拉内容的样式 @@ -190,6 +190,8 @@ }, // 设置下拉菜单处于收起状态 close() { + // 收起的时候将高度设为0,以修复issue # 608 + this.contentHeight = 0 this.$emit('close', this.current); // 设置为收起状态,同时current归位,设置为空字符串 this.active = false;