ant-design-vue/components/icon/icon.vue

51 lines
975 B
Vue
Raw Normal View History

2017-10-26 15:18:08 +08:00
<script>
export default {
name: 'Icon',
props: {
prefixCls: {
default: 'anticon',
type: String,
},
type: String,
title: String,
spin: Boolean,
},
data () {
return {
}
},
computed: {
classes () {
const { prefixCls, type, spin } = this
return {
[`${prefixCls}`]: true,
[`${prefixCls}-${type}`]: type,
[`${prefixCls}-spin`]: !!spin || type === 'loading',
}
},
},
methods: {
handleClick (event) {
if (this.clicked) {
return
}
this.clicked = true
clearTimeout(this.timeout)
this.timeout = setTimeout(() => (this.clicked = false), 500)
this.$emit('click', event)
},
},
2018-01-25 16:29:23 +08:00
render () {
const { title, classes, handleClick } = this
return (
<i title={title} class={classes} onClick={handleClick} />
)
},
2017-10-26 15:18:08 +08:00
beforeDestroy () {
if (this.timeout) {
clearTimeout(this.timeout)
}
},
}
</script>