VUE实现二级菜单分类详情

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>页面标题</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <script src="https://cdn.suoluomei.com/common/js/jquery-2.1.4.min.js"></script>
    <script src="https://cdn.suoluomei.com/common/js2.0/vue/v2.5.16/vue.js"></script>

</head>
<style>
    #Vue {
        display: flex;
        flex-direction: column;
        /*flex-flow: row wrap;*/
    }

    .sort_line {
        padding: 0.5rem;
        background: #00BFFF;
        color: #fff;
        border: 1px solid #00BFFF;
        font-size: 1rem;
        width: 3rem;
        margin: 0.6rem;
        text-align: center;
    }

    .sort_bechoice {
        background: red;
        color: #fff;
    }
    .sort_bechoicetwo{
        background: blue;
        color: #fff;
    }
    .shuju {
        display: flex;
        flex-direction: column;
    }
</style>
<body>
<div id="Vue">
    <div style="display: flex;flex-direction: row;flex-flow: row wrap;">
        <div v-for="(item,index) in assort_list" :key="index">
            <div :class="index == status  ? 'sort_bechoice' : ''" class="sort_line" @click="getchoice(index)">
                {{item.name}}
            </div>
        </div>
    </div>

    <div style="display: flex;flex-direction: row;flex-flow: row wrap;">
        <div v-for="(item,index) in xiaoma" :key="index">
            <div :class="index == statustwo  ? 'sort_bechoicetwo' : ''" class="sort_line" @click="getchoicetwo(index)">
                {{item.name}}
            </div>
        </div>
    </div>

    <div class="shuju">
        <div>
            {{name}}
        </div>
    </div>
</div>
</body>
<script>
    new Vue({
        el: "#Vue",
        data: {
            status: 0,
            statustwo:0,
            assort_list: [
                {
                    name: "老师"
                }, {
                    name: "同学"
                }, {
                    name: "小张"
                }, {
                    name: "阿水"
                }
            ],
            xiaoma:[
                {
                    name: "木瓜"
                }, {
                    name: "西瓜"
                }, {
                    name: "南瓜"
                }, {
                    name: "苦瓜"
                }
            ],
            name: "aaa",

        },
        methods: {
            getchoice(index) {
                let that = this
                this.status = index;
                console.log(index)
                if (index == 0) {
                    that.name = that.name
                    that.xiaoma = [
                        {
                            name: "木瓜"
                        }, {
                            name: "西瓜"
                        }, {
                            name: "南瓜"
                        }, {
                            name: "苦瓜"
                        }
                    ]
                } else if (index == 1) {
                    that.name = 453
                    that.xiaoma = [
                        {
                            name: "没目标"
                        },{
                            name: "没西瓜"
                        },{
                            name: "没橘子"
                        }
                    ]
                } else if (index == 2) {
                    that.name = 789
                    that.xiaoma = [
                        {
                            name: "没南瓜"
                        },{
                            name: "没苦瓜"
                        }
                    ]
                } else if (index == 3) {
                    that.name = 6472
                    that.xiaoma = [
                        {
                            name: "没橘子"
                        }
                    ]
                }
            },
            getchoicetwo(index){
                this.statustwo = index
                if (index == 0){
                    this.name = 123
                }else if(index == 1){
                    this.name = 456
                }else if(index == 2){
                    this.name = 789
                }else if(index == 3){
                    this.name = "aaa"
                }
            }
        },
        created() {
            // $.ajax({
            //     type: "get",	//请求方式
            //     async: false,
            //     url: "",
            //     data: {},		//传值给后台
            //     dataType: "json",
            //     success: function (res) {
            //         console.log(res)
            //
            //     },
            // });
        }
    })
</script>
<script>
    $(document).ready(function () {

    });
</script>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HqL丶1024

创作不易,谢谢打赏!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值