<template>
    <div>
        <van-nav-bar
                title="toast"
                left-arrow
                @click-left="back"
        />
        <div class="page">
            <ul>
                <li class="section">
                    <y-button topic="main" text="加载" v-on:click="fnClick(1)"></y-button>
                </li>
                <li class="section">
                    <y-button topic="main" text="成功" v-on:click="fnClick(2)"></y-button>
                </li>
                <li class="section">
                    <y-button topic="main" text="失败" v-on:click="fnClick(3)"></y-button>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
    import {NavBar} from 'vant';
    import yButton from '../components/yButton'
    import yToast from "../components/yToast";

    export default {
        components: {
            [NavBar.name]: NavBar,
            yButton,
            yToast
        },
        data:()=>{
            return {
                tipsShow:false
            }
        },
        methods:{
            fnClick(type){
                //yToast.success("success");
                //yToast.error("error");
                yToast.loading();
                switch (type) {
                    case 1:
                        yToast.loading("SDfsadf");
                        break;
                    case 2:
                        yToast.success();
                        break;
                    case 3:
                        yToast.error();
                        break;
                }
                setTimeout(yToast.clear,100000);
            },
            back:()=>{
                window.history.go(-1);
            }
        },
        mounted(){
            /*yToast.loading("",{
                type:"car"
            });*/
        }
    }
</script>

<style scoped>
    .page {
        padding: 10px;
    }
</style>
