feat: add scoped slot for icon in menu.js;

新增:为 menus.js 的 icon 增加 scoped slot API;
master
iczer 5 years ago
parent d1f84218c6
commit 58784c81fd
  1. 9
      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))])
]
)]

Loading…
Cancel
Save