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
84
85
86
87
88
89
90
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-toast ref="uToast"></u-toast>
                <u-alert-tips @close="close" :closeAble="closeAble" :show="show" @click="click"
                :type="type" :title="title" :description="description" :showIcon="showIcon"></u-alert-tips>
            </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="1" :list="['是', '否']" @change="showIconChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">关闭图标</view>
                <u-subsection current="1" :list="['显示', '隐藏']" @change="closeAbleChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">主题</view>
                <u-subsection current="3" :list="['primary', 'success', 'error', 'warning', 'info']" @change="typeChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">状态</view>
                <u-subsection :current="current" :list="['开启', '关闭']" @change="showChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                title: '大漠孤烟直,长河落日圆',
                description: "月落乌啼霜满天,江枫渔火对愁眠。姑苏城外寒山寺,夜半钟声到客船。飞流直下三千尺,疑是银河落九天!",
                show: true,
                closeAble: false,
                showIcon: false,
                type: 'warning',
            }
        },
        computed: {
            current() {
                return this.show ? 0 : 1;
            }
        },
        methods: {
            showIconChange(index) {
                this.showIcon = index == 0 ? true : false;
            },
            showChange(index) {
                this.show = index == 0 ? true : false;
            },
            closeAbleChange(index) {
                this.closeAble = index == 0 ? true : false;
            },
            typeChange(index) {
                this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning'  : 'info';
            },
            close() {
                this.show = false;
                this.$refs.uToast.show({
                    type: 'warning',
                    title: '点击关闭按钮'
                })
            },
            click() {
                this.$refs.uToast.show({
                    type: 'warning',
                    title: '点击内容'
                })
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    .wrap {
        padding: 24rpx;
    }
    
    .item {
        margin: 30rpx 0;
    }
</style>