Toast 轻提示
引入
文字提示
import Toast from 'path/to/@vant/weapp/dist/toast/toast';
Toast('我是提示文案,建议不超过十五字~');
Toast.loading({
forbidClick: true,
});
// 自定义加载图标
Toast.loading({
message: '加载中...',
forbidClick: true,
loadingType: 'spinner',
});
成功/失败提示
动态更新提示
const toast = Toast.loading({
duration: 0, // 持续展示 toast
forbidClick: true,
message: '倒计时 3 秒',
});
const timer = setInterval(() => {
second--;
if (second) {
toast.setData({
message: `倒计时 ${second} 秒`,
});
} else {
clearInterval(timer);
Toast.clear();
}
}, 1000);
Toast({
type: 'success',
message: '提交成功',
onClose: () => {
console.log('执行OnClose函数');
});
API
方法
Options