<template>
<a
:class="[
'el-link',
type ? `el-link--${type}` : '',
disabled && 'is-disabled',
underline && !disabled && 'is-underline'
]"
:href="href"
v-bind="$attrs"
@click="handleClick"
>
<el-icon :class="icon" v-if="icon"></el-icon>
<span v-if="$slots.default" class="el-link--inner">
<slot></slot>
</span>
<template v-if="$slots.icon"><slot v-if="$slots.icon" name="icon"></slot></template>
</a>
</template>
<script>
export default {
name: 'ElLink',
props: {
// type 类型 string primary / success / warning / danger / info default
type: {
type: String,
default: 'default'
},
// underline 是否下划线 boolean — true
underline: {
type: Boolean,
default: true
},
// disabled 是否禁用状态 boolean — false
disabled: Boolean,
// href 原生 href 属性
href: String,
// icon 图标类名
icon: String
},
methods: {
handleClick(event) {
if (!this.disabled) {
if (!this.href) {
this.$emit('click', event);
}
}
}
}
};
</script>