Ant-design-mobile: Toast 打开之后不可以立即关闭

Created on 7 May 2018  ·  4Comments  ·  Source: ant-design/ant-design-mobile

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.1.8

Environment

windows chrome: 66.0.3359.139

Reproduction link

https://codepen.io/mylazyprogrammer/pen/MGOYym

Steps to reproduce

Toast.loading('lodaing',0);
if(true){
Toast.hide()
}

What is expected?

期望Toast可以立即关闭

What is actually happening?

Toast不能立即关闭


打开页面之后有一个中转页判断是否登录,登录页面最开始使用Toast.loading()方法;
首先需要判断token标识是否存在;
如果判断token标识不存在的时候跳转到另一个路由页面 ;
此时使用Toast.hide(),无法关闭;
使用setTimeout 延时100毫秒之后可以实现 || 只有在token存在时使用Toast.loading()方法调用请求之后关闭可以实现;
希望可以有使用Toast之后可以立即关闭的机制;

question wontfix

All 4 comments

Translation of this issue:


Toast Cannot Close Immediately After Opening

  • [] I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.1.8

Environment

Windows chrome: 66.0.3359.139

Reproduction link

https://codepen.io/mylazyprogrammer/pen/MGOYym

Steps to reproduce

Toast.loading('lodaing',0);
If(true){
Toast.hide()
}

What is expected?

Expect Toast to shut down immediately

What is actually happening?

Toast cannot be closed immediately


After opening the page there is a transfer page to determine whether to log in. The login page starts with the Toast.loading() method.
First need to determine whether token token exists;
If it is determined that the token does not exist, it will jump to another route page;
Using Toast.hide() at this time cannot be turned off;
Using the setTimeout delay can be achieved after 100 milliseconds || Only when the token is present can be achieved by closing the request after calling the Toast.loading() method;
Hopefully there can be a mechanism that can be closed immediately after using Toast;

你这个需求适合用 ActivityIndicator 组件来做,请查看相应示例。使用 Toast 也不用延时100毫秒,有 setTimeout 就行。

升级antd-mobile后也遇到这个问题了。官方不打算处理这个bug吗?

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tolg picture tolg  ·  4Comments

jkvim picture jkvim  ·  4Comments

zhoujingchao picture zhoujingchao  ·  3Comments

alvin198761 picture alvin198761  ·  3Comments

ArtemSerga picture ArtemSerga  ·  3Comments