vue动态绑定class,tab切换非常好用

谁践踏了优雅 2022-01-15 00:25 439阅读 0赞
  1. <div @click="tab('left')" v-bind:class="{ 'decoration-line':showLeft}" class="col-xs-6 col-md-6 text-center theme-color item" >
  2. 排班信息
  3. </div>
  4. <div @click="tab('right')" v-bind:class="{ 'decoration-line':showRight}" class="col-xs-6 col-md-6 text-center item" >
  5. 医生简介
  6. </div>
  7. data() {
  8. return {
  9. showLeft : true,
  10. showRight : false
  11. }
  12. },
  13. tab(type) {
  14. if (type === 'left'){
  15. this.showLeft = true
  16. this.showRight = false
  17. }else{
  18. this.showLeft = false
  19. this.showRight = true
  20. }
  21. }

发表评论

表情:
评论列表 (有 0 条评论,439人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Vue 动态样式

    1. 简介 本小节我们将介绍 Vue 中如何动态绑定样式。包括 Class 的绑定、内联样式 Style 的绑定。掌握样式绑定的多种形式是其中的重点难点。同学们可以在学完

    相关 vue动态class

    Vue.js 允许您使用 v-bind 指令或简写的 : 来动态绑定 class 属性。这允许您基于某些条件为元素添加或删除类名,从而实现动态样式控制。以下是一些示例: 动态

    相关 vue系列】class动态

    > 操作元素的 class 列表和内联样式是数据绑定的一个常见需求。因为它们都是属性,所以我们可以用 v-bind 处理它们:只需要通过表达式计算出字符串结果即可。不过,字符串