From 11b54e82ed67fd9471a042ee96d6f9fb47b54d4d Mon Sep 17 00:00:00 2001 From: huguangju <huguangju@wowkai.cn> Date: Fri, 19 Feb 2021 16:46:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=89=E6=8B=A9=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E6=BB=9A=E5=8A=A8=E5=88=B0=E5=B7=B2?= =?UTF-8?q?=E9=80=89=E5=9B=BE=E6=A0=87=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/index/IconsDialog.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/views/index/IconsDialog.vue b/src/views/index/IconsDialog.vue index 5b7eb18f..9875488a 100644 --- a/src/views/index/IconsDialog.vue +++ b/src/views/index/IconsDialog.vue @@ -19,7 +19,7 @@ clearable /> </div> - <ul class="icon-ul"> + <ul ref="iconWrap" class="icon-ul"> <li v-for="icon in iconList" :key="icon" @@ -61,12 +61,21 @@ export default { onOpen() { this.active = this.current this.key = '' + this.scrollToActive() }, onClose() {}, onSelect(icon) { this.active = icon this.$emit('select', icon) this.$emit('update:visible', false) + }, + scrollToActive() { + this.$nextTick(() => { + const $activeItem = this.active + ? document.getElementsByClassName('active-item')[0] + : this.$refs.iconWrap.childNodes[0] + $activeItem && $activeItem.scrollIntoView && $activeItem.scrollIntoView() + }) } } }