mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-08 16:37:15 +00:00
Refactor #4351 - For Menu
This commit is contained in:
parent
c57faf3db1
commit
ba6ed5461d
2 changed files with 32 additions and 2 deletions
|
@ -26,7 +26,7 @@
|
|||
<span :class="cx('label')" v-bind="getPTOptions('label')">{{ label() }}</span>
|
||||
</a>
|
||||
</template>
|
||||
<component v-else :is="templates.item" :item="item"></component>
|
||||
<component v-else-if="templates.item" :is="templates.item" :item="item" :label="label()" :props="getMenuItemProps(item)"></component>
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
|
@ -35,6 +35,7 @@
|
|||
import BaseComponent from 'primevue/basecomponent';
|
||||
import Ripple from 'primevue/ripple';
|
||||
import { ObjectUtils } from 'primevue/utils';
|
||||
import { mergeProps } from 'vue';
|
||||
|
||||
export default {
|
||||
name: 'Menuitem',
|
||||
|
@ -83,6 +84,30 @@ export default {
|
|||
},
|
||||
label() {
|
||||
return typeof this.item.label === 'function' ? this.item.label() : this.item.label;
|
||||
},
|
||||
getMenuItemProps(item) {
|
||||
return {
|
||||
action: mergeProps(
|
||||
{
|
||||
class: this.cx('action'),
|
||||
tabindex: '-1',
|
||||
'aria-hidden': true
|
||||
},
|
||||
this.getPTOptions('action')
|
||||
),
|
||||
icon: mergeProps(
|
||||
{
|
||||
class: [this.cx('icon'), item.icon]
|
||||
},
|
||||
this.getPTOptions('icon')
|
||||
),
|
||||
label: mergeProps(
|
||||
{
|
||||
class: this.cx('label')
|
||||
},
|
||||
this.getPTOptions('label')
|
||||
)
|
||||
};
|
||||
}
|
||||
},
|
||||
directives: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue