Toast轻提醒

    引入

    在app.json或index.json中引入组件,默认为ES6版本

    1. "usingComponents": {
    2. "vtu-load-more": "/miniprogram_npm/vtuweapp/loadMore/vtu-load-more"
    3. }

    代码演示

    文字提示

    1. <vtu-btn bind:click="alert1" type="primary" custom-class="dialog-btn">文字提示</vtu-btn>
    2. <vtu-btn bind:click="alert2" type="success" custom-class="dialog-btn">长文字提示</vtu-btn>
    3. <vtu-toast id="Vtu-Toast"></vtu-toast>
    4. import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
    5. Page({
    6. data: {},
    7. alert1() {
    8. Toast('提示内容').then(data => {
    9. Toast('已关闭');
    10. })
    11. },
    12. alert2() {
    13. Toast('这是一条长文字提示,超过一定字数就会换行');
    14. }
    15. });
    16.  

    加载提示

    1. <vtu-btn bind:click="alert3" type="primary" custom-class="dialog-btn">加载提示</vtu-btn>
    2. <vtu-toast id="Vtu-Toast"></vtu-toast>
    3. import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
    4. Page({
    5. data: {},
    6. alert3() {
    7. Toast().loading('成功文案');
    8. }
    9. });

    状态提示

    1. <vtu-btn bind:click="alert4" type="success" custom-class="dialog-btn">成功提示</vtu-btn>
    2. <vtu-btn bind:click="alert5" type="warning" custom-class="dialog-btn">警告提示</vtu-btn>
    3. <vtu-btn bind:click="alert6" type="danger" custom-class="dialog-btn">失败提示</vtu-btn>
    4. <vtu-toast id="Vtu-Toast"></vtu-toast>
    5. import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
    6. Page({
    7. data: {},
    8. alert5() {
    9. Toast().warning('警告文案');
    10. },
    11. alert6() {
    12. Toast().error('失败文案');
    13. }
    14. });

    高级用法

    1. <vtu-btn bind:click="alert7" type="primary" custom-class="dialog-btn">自定义icon</vtu-btn>
    2. <vtu-btn bind:click="alert8" type="warning" custom-class="dialog-btn">带遮罩</vtu-btn>
    3. <vtu-btn bind:click="alert9" type="success" custom-class="dialog-btn">自定义关闭时间</vtu-btn>
    4. <vtu-toast id="Vtu-Toast"></vtu-toast>
    5. import Toast from "../../../miniprogram_npm/vtuweapp/toast/vtu-index";
    6. Page({
    7. data: {},
    8. alert7() {
    9. Toast().alert({
    10. icon: 'iconfont icon-biaoxing',
    11. title: '自定义图标',
    12. rotate: true
    13. });
    14. },
    15. alert8() {
    16. Toast().alert({
    17. icon: 'iconfont icon-biaoxing',
    18. title: '带遮罩',
    19. mask: true
    20. });
    21. },
    22. alert9() {
    23. Toast().alert({
    24. icon: 'iconfont icon-biaoxing',
    25. title: '自定义关闭时间',
    26. duration: 5000
    27. }).then(data => {
    28. Toast('已关闭');
    29. })
    30. }
    31. });

    组件参数

    Toast 轻提醒 - 图1