<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Vue.js实现简单的Tab切换效果播</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <style> .active { color: red; cursor: pointer; } .unactive { color: black; cursor: pointer; } </style> </head> <body> <div id="app"> <ul v-for="(menu,index) in menus"> <li :id="'menu'+menu.id" @click="menuClick(index)" :class="{'active':index===num}">{{menu.name}}</li> </div> </body> <script type="text/javascript"> var vm = new Vue({ el: "#app", data: { num: 0, menus: [ { id: 1, name: "新闻", icon: "../xx.png" }, { id: 2, name: "产品", icon: "../xx.png" }, { id: 3, name: "动态", icon: "../xx.png" } ] }, methods: { menuClick: function(index) { this.num = index; } } }); </script> </html>
https://baijiahao.baidu.com/s?id=1698978486875222364&wfr=spider&for=pc
一片空白 5.8万
父爱如山,不善表达。回想十多年前,总记得父亲有个宽厚的肩膀,小小的自己跨坐在上面,越过人山人海去看更广阔的天空,那个时候期望自己有一双翅膀,能够像鸟儿一样飞得高,看得远。虽然父亲有时会和自己开玩笑,但在做错事的时候会受到严厉的训斥。父亲有双粗糙的大手掌。