vue简单的table切换 不使用路由

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .fir>li{
            width: 50px;
            height: 50px;
            border: 1px solid ;
            float: left;
            line-height: 50px ;
            text-align: center;
        }
    </style>
</head>
<body>
<div id="app">
    <ul class="fir">
        <li v-for="x,index in dao" @click="tab(index)">{{x}}</li>
    </ul>
    <div>
        <div v-for="i,index in content" class="cont" v-if="index==num">{{i}}</div>
    </div>
</div>
</body>
<script src="vue.js"></script>
<script>
    const vm=new Vue({
        el:"#app",
        data:{
            dao:["dao1","dao2","dao3"],
            content:["c11","c22","c33"],
            num:0
        },
        methods:{
            tab(sza){
                this.num=sza
            }
        }
    })
</script>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_42413689/article/details/81710532
今日推荐