Skip to content

Commit 87e5985

Browse files
nanjingcaiyongcaiyong
and
caiyong
authored
fix: the button's loading property without delay (#3194)
Co-authored-by: caiyong <[email protected]>
1 parent 8da63a6 commit 87e5985

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

components/button/button.tsx

+14-11
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,25 @@ export default defineComponent({
2727
large: 'lg',
2828
small: 'sm',
2929
},
30-
sLoading: !!this.loading,
30+
sLoading: false,
3131
hasTwoCNChar: false,
3232
};
3333
},
3434
watch: {
35-
loading(val, preVal) {
36-
if (preVal && typeof preVal !== 'boolean') {
37-
clearTimeout(this.delayTimeout);
38-
}
39-
if (val && typeof val !== 'boolean' && val.delay) {
40-
this.delayTimeout = setTimeout(() => {
35+
loading: {
36+
handler(val, preVal) {
37+
if (preVal && typeof preVal !== 'boolean') {
38+
clearTimeout(this.delayTimeout);
39+
}
40+
if (val && typeof val !== 'boolean' && val.delay) {
41+
this.delayTimeout = setTimeout(() => {
42+
this.sLoading = !!val;
43+
}, val.delay);
44+
} else {
4145
this.sLoading = !!val;
42-
}, val.delay);
43-
} else {
44-
this.sLoading = !!val;
45-
}
46+
}
47+
},
48+
immediate: true,
4649
},
4750
},
4851
mounted() {

0 commit comments

Comments
 (0)