vue学习八

    <div id="app8">
        <ul>
            <li v-for="(item,index) in list" style="display: inline;list-style-type: none;
            margin-left: 10px;" @click="indexactive = index">
            <a href="javascript:void(0)"
             :key="item.id" :class="{active : indexactive === index}">
                {{ item.name }}</a>
            </li>
        </ul>
    </div>
    <script>
        const app8=new Vue({
            el:'#app8',
            data:{
                indexactive:0,
                list:[
                    {id:0,name:'京东'},
                    {id:1,name:'淘宝'},
                    {id:2,name:'拼夕夕'}
                ]
            }
        })
    </script>

 

posted @ 2023-10-20 16:22  子过杨梅  阅读(2)  评论(0编辑  收藏  举报