且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

vue.js - vue样式切换

更新时间:2022-10-19 13:00:12

你应该是想做成 radio 的效果

<div>
    <div :class="{ active: type === 'teacher'}" @click="change('teacher')">
        老师
    </div>
    <div :class="{ active: type === 'student'}" @click="change('student')">
        学生
    </div>
</div>

data () {
  return {
    type: null
  }
},
methods:{
  change (type) {
    this.type= type
  }
}