Router-Link组件默认支持激活样式显示的类名,只需要给active-class属性设置对应的类名即可
<RouterLink active-class="active" :to="`/category/${item.id}`">{{ item.name }}</RouterLink>
<style scoped lang='scss'>
.active {
color: $xtxColor;
border-bottom: 1px solid $xtxColor;
}
</style>
图例: