作者:mobiledu2502916573 | 来源:互联网 | 2023-05-17 12:26
小程序中并不能像H5一样直接使用alert弹出消息提示,因此可以选择使用wx.showToast的API进行消息提示,但是官方只支持success和loading两种样式。重新写一个
小程序中并不能像H5一样直接使用alert弹出消息提示,因此可以选择使用 wx.showToast 的API进行消息提示,但是官方只支持success 和 loading 两种样式。重新写一个 toast 组件成本略高,因此考虑直接使用现成的 wepy-com-toast 组件。使用方法如下:
1 . 安装组件
npm install wepy-com-toast
2 .无缓存编译
wepy build --no-cache
3 .需要的组件中引入 toast 组件
<template> <toast /> template> <script> import wepy from 'wepy'; import Toast from 'wepy-com-toast'; export default class Index extends wepy.page { compOnents= { toast: Toast }; } script>
4 .调用
this.$invoke('toast', 'show', { title: '系统繁忙', img: 'https://yourpicture.com/sad.png', });