-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(switch): support beforeChange API (#4699)
* feat(switch): support beforeChange API closed #848 * chore: fix typo * chore: fix typo * chore: update snapshot * chore: fix typo --------- Co-authored-by: wū yāng <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
bfa36a2
commit 62e4718
Showing
9 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<t-space> | ||
<t-switch | ||
v-model="resolveChecked" | ||
:loading="loadingResolve" | ||
:before-change="beforeChangeResolve" | ||
@change="onChangeResolve" | ||
/> | ||
<t-switch | ||
v-model="rejectChecked" | ||
:loading="loadingReject" | ||
:before-change="beforeChangeReject" | ||
@change="onChangeReject" | ||
/> | ||
</t-space> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
const resolveChecked = ref(true); | ||
const rejectChecked = ref(true); | ||
const loadingResolve = ref(false); | ||
const loadingReject = ref(false); | ||
const onChangeResolve = (v) => { | ||
console.log(v); | ||
}; | ||
const onChangeReject = (v) => { | ||
console.log(v); | ||
}; | ||
const beforeChangeResolve = () => { | ||
loadingResolve.value = true; | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
loadingResolve.value = false; | ||
resolve(true); | ||
}, 1000); | ||
}); | ||
}; | ||
const beforeChangeReject = () => { | ||
loadingReject.value = true; | ||
return new Promise((_resolve, reject) => { | ||
setTimeout(() => { | ||
loadingReject.value = false; | ||
reject(new Error('reject')); | ||
}, 1000); | ||
}); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters