你觉得你过不去的坎的时候,有一天也会乐观的和别人分享。或许这就是成长。有时候,闭上眼睛,放下骄傲,承认是自己错了,不是认输,而是成长。
本文介绍了Vue2.0 实现单选互斥的方法,分享给大家,具体如下:
需要实现如上图的功能
1. 首次加载页面,根据data里的catgoryId高亮对应的选项
2. 点击某个选项,该选项高亮,其他去掉高亮
代码结构:
<template>
<dd @click="changeCategory(currCourseFirst.categoryId)"
v-for="currCourseFirst in currCourse.currCourseFirst"
:key="currCourseFirst.categoryId"
:class="resultCategoryId === currCourseFirst.categoryId ? 'active': ''" >
{{currCourseFirst.name}}
</dd>
</template>
<script>
export default{
data() {
return {
categeryId: this.$route.query.categoryId,
typeId: this.$route.query.typeId
}
},
methods: {
changeCategoryId(categoryId) {
this.categoryId = categoryId
}
},
computed: {
resultCategoryId(){
return this.categoryId
}
}
}
</script>
自我理解
参考链接://www.haodaima.com/article/138185.htm
本文Vue2.0 如何实现单选互斥的方法到此结束。因为某人不如你所愿爱你,并不意味着你不被别人所爱。小编再次感谢大家对我们的支持!




