时间:2021-07-01 10:21:17 帮助过:8人阅读
如下所示:
<!DOCTYPE html> <html lang="en"> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!--<link href="css/style.css" rel="external nofollow" rel="stylesheet">--> <script src="js/jquery.js"></script> <script src="js/vue(2.0).js"></script> <style lang="less" rel="stylesheet/less"> .a { display: block; float: left; margin-left: 20px; } .active { color: red; font-size: 17px; } </style> </head> <body> <p id="app"> <a class="s-bt" @click="selected(Aname.name)" :class="{active: active == Aname.name}" v-for="Aname in Alist">{{Aname.name}}</a> </p> <script> new Vue({ el: '#app', data: { Alist: [{ name: '影视大咖' }, { name: '女明星' }, { name: '男明星' }, { name: '商业大亨' }], active: '' }, mounted() { }, methods: { selected(name) { this.active = name; } } }) </script> </body> </html>
相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!
推荐阅读:
echarts鼠标覆盖高亮显示节点关系数实现步骤
nodejs生成二维码(最简洁)
以上就是用vue让a标签点击高亮(附代码)的详细内容,更多请关注Gxl网其它相关文章!