zhangxiaoxu123456
2021-12-20 301289e539c417995f95f5cb91fd1f6043bb7cfd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-toast :type="type" ref="uToast"></u-toast>
                <text class="no-mode-here">见弹出toast</text>
            </view>
        </view>
        <view class="u-config-wrap">
            <view class="u-config-title u-border-bottom">
                参数配置
            </view>
            <view class="u-config-item">
                <view class="u-item-title">主题</view>
                <u-subsection :current="4" :list="['primary', 'success', 'error', 'warning', 'default']" @change="typeChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">结束后自动跳转</view>
                <u-subsection current="1" :list="['是', '否']" @change="urlChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">位置</view>
                <u-subsection current="1" :list="['顶部', '中部', '底部']" @change="positionChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">显示图标</view>
                <u-subsection :list="['是', '否']" @change="iconChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                type: 'success',
                title: '桃花潭水深千尺',
                icon: true,
                position: 'center',
                url: '',
            }
        },
        methods: {
            typeChange(index) {
                this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning'  : 'default';
                this.show();
            },
            positionChange(index) {
                this.position = index == 0 ? 'top' : index == 1 ? 'center' : 'bottom';
                this.show();
            },
            iconChange(index) {
                this.icon = index == 0 ? true : false;
                this.show();
            },
            urlChange(index) {
                this.url = index == 0 ? '/pages/components/button/index' : '';
                this.show();
            },
            show() {
                this.$refs.uToast.show({
                    title: this.title,
                    position: this.position,
                    type: this.type,
                    icon: this.icon,
                    url: this.url,
                });
            },
            hide() {
                this.$refs.uToast.hide();
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .no-mode-here {
        color: $u-tips-color;
        font-size: 28rpx;
    }
</style>