<template>
<je-button :type="type" :size="size" :disabled="disabled" @click="singleClick">
<slot></slot>
</je-button>
</template>
<script>
const Status = (function () {
let loading = false
function lock() {
loading = true
}
function unlock() {
loading = false
}
function getStatus() {
return loading
}
return {
lock,
unlock,
getStatus,
}
})()
export default {
name: 'singleClick',
props: {
type: String,
size: String,
disabled: {
type: Boolean,
default: false,
},
isloading: {
type: Boolean,
default: false,
},
},
watch: {
isloading(newVal, oldVal) {
if (newVal == false) {
Status.unlock()
}
},
},
methods: {
singleClick() {
if (Status.getStatus()) return
Status.lock()
this.$emit('update:isloading', true)
this.$emit('click')
},
},
}
</script>
<style lang="less" scoped></style>
评论