diff --git a/example/pages/toast/index.js b/example/pages/toast/index.js index e0f091b2..2684a09f 100644 --- a/example/pages/toast/index.js +++ b/example/pages/toast/index.js @@ -42,6 +42,14 @@ Page({ }); }, + showEverToast() { + Toast({ + message: 'toast的内容', + selector: '#zan-toast-test', + timeout: -1 + }); + }, + showLoading() { Toast.loading({ message: '加载中', diff --git a/example/pages/toast/index.wxml b/example/pages/toast/index.wxml index 9a8edf73..616af1db 100644 --- a/example/pages/toast/index.wxml +++ b/example/pages/toast/index.wxml @@ -25,6 +25,10 @@ 只显示图标的toast + + 不消失的的toast + + 显示 Loading diff --git a/packages/toast/README.md b/packages/toast/README.md index 3027698d..89902351 100644 --- a/packages/toast/README.md +++ b/packages/toast/README.md @@ -52,4 +52,4 @@ Toast.loading({ | type | 提示类型 | String | - | loading success fail | | icon | toast 显示图标,可以用 icon 里面支持的所有图标 | String | - | - | | image | toast 显示图标,为图片的链接,传入此值后会覆盖 icon 值 | String | - | | -| timeout | toast 显示时间,小于0则会一直显示,需要手动调用 clearZanToast 清除 | Number | - | | +| timeout | toast 显示时间,小于0则会一直显示,需要手动调用 Toast.clear 清除 | Number | - | | diff --git a/packages/toast/toast.js b/packages/toast/toast.js index a8c41b00..55a8f177 100644 --- a/packages/toast/toast.js +++ b/packages/toast/toast.js @@ -57,9 +57,14 @@ function Toast(optionsOrMsg, pageCtx) { show: true }); - const timeoutId = setTimeout(() => { - toastCtx.clear(); - }, parsedOptions.timeout || 3000); + let timeoutId = 0; + + if (parsedOptions.timeout >= 0) { + timeoutId = setTimeout(() => { + toastCtx.clear(); + }, parsedOptions.timeout || 3000); + } + timeoutData = { timeoutId,