Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [toast] API调用,多次调用时,对于后续未传入的参数,会重复使用之前传入的参数值的问题。修改为,对未传入的参数使用默认值。 #230

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions example/pages/toast/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ Page({
Toast({
context: this,
selector: '#t-toast',
icon: '',
theme: '',
direction: 'row',
placement: 'middle',
preventScrollThrough: false,
duration: 2000,
...option,
});
},
Expand Down
12 changes: 11 additions & 1 deletion src/toast/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ export default class Toast extends SuperComponent {

properties = Props;

show(options: TdToastProps) {
show(userOptions: TdToastProps) {
const options = {
message: '',
icon: '',
theme: '',
direction: 'row',
placement: 'middle',
preventScrollThrough: false,
duration: 2000,
...userOptions,
};
if (this.hideTimer) clearTimeout(this.hideTimer);
if (this.removeTimer) clearTimeout(this.removeTimer);
const typeMapIcon =
Expand Down