uni-app的API中,showToast的icon值只有success,loading,none三种显示,失败没有图标。如果失败时需要显示图标,就要用到自定义图标 image 了。

1     uni.showToast({
2         title: '扫码失败',
3         image:'/static/lost.png',   //要写根路径,不要写相对路径
4         duration: 3000,
5     })

结果如下:

 uni-app之uni.showToast()image路径问题

 

特别意:
在components下的组件,图片路径用 /static/lost.png 这样的根路径形式,不要用…/static 或者 …/…/static 的形式。
在有些平台不报错也不显示,有些找不到路径。

相关文章:

  • 2022-02-20
  • 2021-12-10
  • 2022-12-23
  • 2021-10-22
  • 2021-09-10
  • 2021-07-12
  • 2022-12-23
  • 2021-04-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-08-17
  • 2021-08-04
  • 2021-11-15
相关资源
相似解决方案