首页 > 编程 > JavaScript > 正文

Vue2.0 实现单选互斥的方法

2019-11-19 14:01:38
字体:
来源:转载
供稿:网友

本文介绍了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.VeVB.COm/article/138185.htm

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表