改变事件执行顺序
作者:互联网
<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>
标签:顺序,console,log,null,inputLoading,submit,事件,const,执行 来源: https://www.cnblogs.com/whh666/p/15872979.html