iview/src/components/dropdown/dropdown-item.vue

54 lines
1.5 KiB
Vue
Raw Normal View History

<template>
<li :class="classes" @click="handleClick"><slot></slot></li>
</template>
<script>
const prefixCls = 'ivu-dropdown-item';
export default {
props: {
key: {
type: [String, Number]
},
disabled: {
type: Boolean,
default: false
},
selected: {
type: Boolean,
default: false
},
divided: {
type: Boolean,
default: false
}
},
computed: {
classes () {
return [
`${prefixCls}`,
{
[`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-selected`]: this.selected,
[`${prefixCls}-divided`]: this.divided
}
]
}
},
methods: {
handleClick () {
2016-12-04 13:52:51 +08:00
const $parent = this.$parent.$parent;
if (this.disabled) {
this.$nextTick(() => {
2016-12-04 13:52:51 +08:00
$parent.visible = true;
});
} else {
2016-12-04 13:52:51 +08:00
if ($parent.trigger === 'hover') {
$parent.visible = false;
$parent.$emit('on-hover-click');
2016-12-04 00:38:57 +08:00
}
}
2016-12-04 13:52:51 +08:00
$parent.$emit('on-click', this.key);
}
}
}
</script>