SoFunction
Updated on 2025-04-04

vue implements a tag click highlight method

As shown below:

<!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/" rel="external nofollow" rel="stylesheet">-->
<script
src="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>
<div
>
<a
class="s-bt" @click="selected()"
 :class="{active: active == }"
v-for="Aname in Alist">{{}}</a>
</div>
<script>
new
Vue({
el:
'#app',
data: {
Alist: [{
name:
'Movie and TV Star'
}, {
name:
'Female Star'
}, {
name:
'Male Star'
}, {
name:
'Business Tycoon'
}],
active:
''
},
mounted() {
},
methods: {
selected(name) {

= name;
}
}
})
</script>
</body>
</html>

The above method of clicking highlighting the vue tag to realize the A tag is all the content I share with you. I hope you can give you a reference and I hope you can support me more.