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

先看案例如图所示

话不多说上代码:

<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>

猜你喜欢

转载自blog.csdn.net/qq_44224811/article/details/128806267
今日推荐