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

[Toast] 提供一个属性在 页面onHide时,自动关闭Toast未销毁的定时Toast #1921

Closed
de1ck opened this issue Apr 23, 2023 · 5 comments · Fixed by #1947
Closed
Assignees
Labels
question This is a question, not a bug

Comments

@de1ck
Copy link

de1ck commented Apr 23, 2023

这个功能解决了什么问题

小程序在SwitchBar的时候,页面组件不会被销毁,这会导致页面切换Tab时,上一个页面的Toast提示在存在。

你建议的方案是什么

目前我的一种方案是重写 Page的onHide事件

let onHide = context.onHide;
// eslint-disable-next-line no-unused-vars
context.onHide = function (...arg) {
  // console.log('onHide#######');
  onHide.apply(this, arg);
 // 手动关闭 Toast
  toast.clear();
  context.onHide = onHide;
};
@github-actions
Copy link
Contributor

👋 @de1ck,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@de1ck de1ck changed the title [Toast] 提供一个属性在 页面onHide时,自动关闭Toast未销毁的定时Toast? [Toast] 提供一个属性在 页面onHide时,自动关闭Toast未销毁的定时Toast Apr 23, 2023
@github-actions
Copy link
Contributor

♥️ 有劳 @LeeJim 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @de1ck

@LeeJim
Copy link
Collaborator

LeeJim commented Apr 26, 2023

这个 toast 是 wx.showToast 吧?应该不是 t-toast?

@LeeJim LeeJim added the question This is a question, not a bug label Apr 26, 2023
@de1ck
Copy link
Author

de1ck commented Apr 26, 2023

这个 toast 是 wx.showToast 吧?应该不是 t-toast?

wx.showToast切换页面还会在,级别比较高,类似root节点下的t-toast ,t-toast在切换页面是不会显示的,但是切换回来可能还会存在。

@LeeJim
Copy link
Collaborator

LeeJim commented Apr 27, 2023

这个就属于业务自己的逻辑了,组件库底层不适合做这样的处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question, not a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants