-
Notifications
You must be signed in to change notification settings - Fork 358
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
- Loading branch information
1 parent
37e7fb7
commit 8740abc
Showing
8 changed files
with
117 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<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> | ||
export default { | ||
data() { | ||
return { | ||
resolveChecked: true, | ||
rejectChecked: true, | ||
loadingResolve: false, | ||
loadingReject: false, | ||
}; | ||
}, | ||
methods: { | ||
onChangeResolve(val) { | ||
console.log('onChangeResolve', val); | ||
}, | ||
onChangeReject(val) { | ||
console.log('onChangeReject', val); | ||
}, | ||
beforeChangeResolve() { | ||
this.loadingResolve = true; | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
this.loadingResolve = false; | ||
resolve(true); | ||
}, 1000); | ||
}); | ||
}, | ||
beforeChangeReject() { | ||
this.loadingReject = true; | ||
return new Promise((_resolve, reject) => { | ||
setTimeout(() => { | ||
this.loadingReject = 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