From 58784c81fdc39c42697b5b73caadbe2dd6bb313a Mon Sep 17 00:00:00 2001 From: iczer <1126263215@qq.com> Date: Thu, 27 Aug 2020 18:55:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20scoped=20slot=20for=20icon=20in?= =?UTF-8?q?=20menu.js;=20:star:=20=E6=96=B0=E5=A2=9E=EF=BC=9A=E4=B8=BA=20m?= =?UTF-8?q?enus.js=20=E7=9A=84=20icon=20=E5=A2=9E=E5=8A=A0=20scoped=20slot?= =?UTF-8?q?=20API=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/menu/menu.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/menu/menu.js b/src/components/menu/menu.js index 9e75bd2..d21ad6d 100644 --- a/src/components/menu/menu.js +++ b/src/components/menu/menu.js @@ -119,7 +119,10 @@ export default { } }, methods: { - renderIcon: function (h, icon) { + renderIcon: function (h, icon, key) { + if (this.$scopedSlots.icon) { + return this.$scopedSlots.icon({icon, key}) + } return !icon || icon == 'none' ? null : h(Icon, {props: {type: icon}}) }, renderMenuItem: function (h, menu) { @@ -128,7 +131,7 @@ export default { [ h('router-link', {props: {to: menu.fullPath}}, [ - this.renderIcon(h, menu.meta ? menu.meta.icon : 'none'), + this.renderIcon(h, menu.meta ? menu.meta.icon : 'none', menu.fullPath), h('span', [this.$t(getI18nKey(menu.fullPath))]) ] ) @@ -139,7 +142,7 @@ export default { let this_ = this let subItem = [h('span', {slot: 'title'}, [ - this.renderIcon(h, menu.meta ? menu.meta.icon : 'none'), + this.renderIcon(h, menu.meta ? menu.meta.icon : 'none', menu.fullPath), h('span', [this.$t(getI18nKey(menu.fullPath))]) ] )]