提示框
参数 | 类型 | 描述 |
---|---|---|
options | object |
配置项 |
options.type | string |
提示类型 |
options.timer | number |
提示延迟时间 |
options.color | string |
图标颜色 |
options.text | string |
提示文本 |
options.success | function |
关闭后的回调函数 |
Example
<import src="../../components/toast/toast.wxml"/>
<template is="toast" data="{{ ...$wux.toast }}"/>
<view class="page">
<view class="page__hd">
<view class="page__title">Toast</view>
<view class="page__desc">提示框</view>
</view>
<view class="page__bd">
<view class="weui-btn-area">
<button class="weui-btn" type="default" bindtap="showToast">成功提示</button>
<button class="weui-btn" type="default" bindtap="showToastCancel">取消提示</button>
<button class="weui-btn" type="default" bindtap="showToastErr">禁止提示</button>
<button class="weui-btn" type="default" bindtap="showToastText">文本提示</button>
</view>
</view>
</view>
import { $wuxToast } from '../../components/wux'
Page({
data: {},
onLoad() {},
showToast() {
$wuxToast.show({
type: 'success',
timer: 1500,
color: '#fff',
text: '已完成',
success: () => console.log('已完成')
})
},
showToastCancel() {
$wuxToast.show({
type: 'cancel',
timer: 1500,
color: '#fff',
text: '取消操作',
success: () => console.log('取消操作')
})
},
showToastErr() {
$wuxToast.show({
type: 'forbidden',
timer: 1500,
color: '#fff',
text: '禁止操作',
success: () => console.log('禁止操作')
})
},
showToastText() {
$wuxToast.show({
type: 'text',
timer: 1500,
color: '#fff',
text: '文本提示',
success: () => console.log('文本提示')
})
},
})