<template>
<el-input @blur="onBlur" v-model="input" placeholder="Please input" style="width:200px" />
<el-button @click="submitFn" type="primary">提交</el-button>
</template>
<script>
import { reactive, toRefs, ref } from 'vue'
export default {
setup () {
const input = ref('')
let inputLoading = null
const onBlur = () => {
inputLoading = new Promise(resolve => {
console.log('onBlurStart')
setTimeout(() => {
console.log('onBlurEnd')
resolve()
}, 2000)
}).finally(() => {
inputLoading = null
})
}
const submitFn = () => {
if (inputLoading) {
inputLoading.then(() => {
console.log('submit', 22)
})
} else {
console.log('submit', 11)
}
}
return { input, onBlur, submitFn }
}
}
</script>
<style>
</style>