uview 中u-tabs如何做tab切换?

  • Post author:
  • Post category:其他


先看案例如图所示


话不多说上代码:

<template>
  <view class="treeroot">
    <view class="">
      <u-tabs 
      :list="list" 
      :is-scroll="false" 
      :current="current" 
      bar-width="50" 
      active-color="orange" 
      @change="change">
      </u-tabs>
      <view v-if="current == 0">
        11
      </view>
      <view v-if="current == 1">
        22
      </view>
    </view>
  </view>
</template>
<script>
  export default {
    data() {
      return {
        //
        list: [{
            name: "额度恢复记录",
          },
          {
            name: "还款记录",
          },
        ],
        //默认展开第几项
        current: 0,
      };
    },
    methods: {
      change(index) {
        this.current = index;
        //如报错则用this.current = index.index;代替上面这句
      },
    },
  };
</script>

<style scoped lang="scss">
 
</style>



版权声明:本文为qq_44224811原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。