vue实现a标签点击切换高亮方法
<template> <div id="app"> <a class="s-bt" @click="selected(1)" :class="{active: active == 1}">aaa</a> <a class="s-bt" @click="selected(2)" :class="{active: active == 2}">bbb</a> </div> </template> <script> export default { name: "Analysis", data() { return { active: '1' } } }, mounted() { }, methods: { selected(flag) { this.active = flag; } } </script> <style lang="scss" scoped> .active { color: red; font-size: 17px; } </style>