Toast轻提醒
引入
在app.json或index.json中引入组件,默认为ES6版本
"usingComponents": {
"vtu-load-more": "/miniprogram_npm/vtuweapp/loadMore/vtu-load-more"
}
代码演示
文字提示
<vtu-btn bind:click="alert1" type="primary" custom-class="dialog-btn">文字提示</vtu-btn>
<vtu-btn bind:click="alert2" type="success" custom-class="dialog-btn">长文字提示</vtu-btn>
<vtu-toast id="Vtu-Toast"></vtu-toast>
import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
Page({
data: {},
alert1() {
Toast('提示内容').then(data => {
Toast('已关闭');
})
},
alert2() {
Toast('这是一条长文字提示,超过一定字数就会换行');
}
});
加载提示
<vtu-btn bind:click="alert3" type="primary" custom-class="dialog-btn">加载提示</vtu-btn>
<vtu-toast id="Vtu-Toast"></vtu-toast>
import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
Page({
data: {},
alert3() {
Toast().loading('成功文案');
}
});
状态提示
<vtu-btn bind:click="alert4" type="success" custom-class="dialog-btn">成功提示</vtu-btn>
<vtu-btn bind:click="alert5" type="warning" custom-class="dialog-btn">警告提示</vtu-btn>
<vtu-btn bind:click="alert6" type="danger" custom-class="dialog-btn">失败提示</vtu-btn>
<vtu-toast id="Vtu-Toast"></vtu-toast>
import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
Page({
data: {},
alert5() {
Toast().warning('警告文案');
},
alert6() {
Toast().error('失败文案');
}
});
高级用法
<vtu-btn bind:click="alert7" type="primary" custom-class="dialog-btn">自定义icon</vtu-btn>
<vtu-btn bind:click="alert8" type="warning" custom-class="dialog-btn">带遮罩</vtu-btn>
<vtu-btn bind:click="alert9" type="success" custom-class="dialog-btn">自定义关闭时间</vtu-btn>
<vtu-toast id="Vtu-Toast"></vtu-toast>
import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
Page({
data: {},
alert7() {
Toast().alert({
icon: 'iconfont icon-biaoxing',
title: '自定义图标',
rotate: true
});
},
alert8() {
Toast().alert({
icon: 'iconfont icon-biaoxing',
title: '带遮罩',
mask: true
});
},
alert9() {
Toast().alert({
icon: 'iconfont icon-biaoxing',
title: '自定义关闭时间',
duration: 5000
}).then(data => {
Toast('已关闭');
})
}
});
组件参数