<body>

    <div id="app">
        <p v-for="(item,$index) in arr" @click="toggle($index)" :class="{active:$index==active}">{{item}}</p>
    </div>
    <!-- Add your site or application content here -->




    <script>
        var app=new Vue({
            el:'#app',
            data:{
               active:0,
                arr:[
                    "新闻",
                    "视频",
                    "社会",
                    "军事",
                    "军事1",
                    "军事2",
                    "军事3",
                    "军事4",
                ]

            },
            computed:{

            },
            methods:{
                toggle(index){
                    this.active=index
                }
            },
        })



    </script>
</body>
Logo

前往低代码交流专区

更多推荐