vant icon indicating copy to clipboard operation
vant copied to clipboard

[Bug Report] Toast的type切换时渲染内容错误

Open FeiFanLiang opened this issue 4 years ago • 10 comments

重现链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个Toast调用时,在使用type:html后其他类型的Toast提示内容均无法显示,只能显示空白内容

重现步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

No response

FeiFanLiang avatar Feb 15 '22 17:02 FeiFanLiang

你好 我也出现了这个问题 我的样式是通过vite自动导入的

Ali-ovo avatar Feb 16 '22 01:02 Ali-ovo

重现链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个Toast调用时,在使用type:html后其他类型的Toast提示内容均无法显示,只能显示空白内容

重现步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

No response

image

本地调试了一下,发现Toast组件内的renderMessage函数在Toast重新调用时重新执行了,但是实际渲染出的dom元素没有渲染出type:text中的message,猜测原因可能是vnode的复用导致没有正常进行更新,如上图分别使用key值后,此时进行不同类型的调用,行为正常

FeiFanLiang avatar Feb 16 '22 04:02 FeiFanLiang

重新链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个 Toast 调用时,在使用type:html后显示其他内容类型的 Toast 提示内容均无法显示,只能空白处

返回步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

没有反应

图片

调试了一下,Toast 组件内的renderMessage 函数在Toast 重新调用时重新执行,但是实际上渲染出的dom 没有渲染出type:text的消息,估计原因可能是vnode 的复用导致没有正常进行图分别使用关键值后,此时进行不同类型的调用,行为正常

你这个问题应该是类名重复 导致你提示框的背景颜色为白色 我的解决方案是 给这个提示框给定一个自定义类名 然后在全局样式中把这个类名的背景颜色设置成黑色 这样提示框出来就不会是白屏的了

Ali-ovo avatar Feb 16 '22 06:02 Ali-ovo

重现链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个Toast调用时,在使用type:html后其他类型的Toast提示内容均无法显示,只能显示空白内容

重现步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

No response 112 在这里是了这个例子未发现呀

1365436742 avatar Feb 17 '22 09:02 1365436742

const showMultipleToast = () => { Toast.allowMultiple(); Toast({ type: 'html', message: '<b>1</b>', position: 'top', }); Toast({ type: 'fail', message: t('text3'), position: 'bottom', }); }; 这里的写法是这样的

1365436742 avatar Feb 17 '22 09:02 1365436742

const showMultipleToast = () => { Toast.allowMultiple(); Toast({ type: 'html', message: '<b>1</b>', position: 'top', }); Toast({ type: 'fail', message: t('text3'), position: 'bottom', }); }; 这里的写法是这样的

重现链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个Toast调用时,在使用type:html后其他类型的Toast提示内容均无法显示,只能显示空白内容

重现步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

No response 112 在这里是了这个例子未发现呀

我是这样使用出现的问题 A->B页面 然后B页面在返回A的同时 进行Toast提示 就会出现这个问题

Ali-ovo avatar Feb 17 '22 09:02 Ali-ovo

const showMultipleToast = () => { Toast.allowMultiple(); Toast({ type: 'html', message: '<b>1</b>', position: 'top', }); Toast({ type: 'fail', message: t('text3'), position: 'bottom', }); }; 这里的写法是这样的

重现链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个Toast调用时,在使用type:html后其他类型的Toast提示内容均无法显示,只能显示空白内容

重现步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

No response 112 在这里是了这个例子未发现呀

我是这样使用出现的问题 A->B页面 然后B页面在返回A的同时 进行Toast提示 就会出现这个问题

你这里可能是生命周期运用的问题,可以贴出你的代码

1365436742 avatar Feb 17 '22 09:02 1365436742

就很简单的一个点击事件 然后 toast提示 然后router.go(-2) image

Ali-ovo avatar Feb 17 '22 09:02 Ali-ovo

const showMultipleToast = () => { Toast.allowMultiple(); Toast({ type: 'html', message: '<b>1</b>', position: 'top', }); Toast({ type: 'fail', message: t('text3'), position: 'bottom', }); }; 这里的写法是这样的

重现链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个Toast调用时,在使用type:html后其他类型的Toast提示内容均无法显示,只能显示空白内容

重现步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

No response 112 在这里是了这个例子未发现呀

我是这样使用出现的问题 A->B页面 然后B页面在返回A的同时 进行Toast提示 就会出现这个问题

你这里可能是生命周期运用的问题,可以贴出你的代码

复现链接 Toast调用时使用不同type造成的渲染异常,可以尝试先点击其他类型的type按钮再点击html内容按钮,然后再点击其他类型type,此时Toast内容的message文本为空

另外一个Toast和Dialog引起的样式问题,需要在生产模式进行按需加载的情况才会出现

FeiFanLiang avatar Feb 18 '22 11:02 FeiFanLiang

重新链接

描述

Vant 版本

3.4.1

描述一下你遇到的问题。

页面同时存在多个 Toast 调用时,在使用type:html后显示其他内容类型的 Toast 提示内容均无法显示,只能空白处

返回步骤

Toast({type:'html',message:'<b>1</b>'}) Toast({type:"fail",message:"1"})

设备/浏览器

没有反应

图片 调试了一下,Toast 组件内的renderMessage 函数在Toast 重新调用时重新执行,但是实际上渲染出的dom 没有渲染出type:text的消息,估计原因可能是vnode 的复用导致没有正常进行图分别使用关键值后,此时进行不同类型的调用,行为正常

你这个问题应该是类名重复 导致你提示框的背景颜色为白色 我的解决方案是 给这个提示框给定一个自定义类名 然后在全局样式中把这个类名的背景颜色设置成黑色 这样提示框出来就不会是白屏的了

这个issue讨论的不是这个bug,那个在另外一个

FeiFanLiang avatar Feb 18 '22 11:02 FeiFanLiang