• uniapp微信小程序自定义封装分段器。


    uniapp微信小程序自定义封装分段器。

    话不多说先上效果
    在这里插入图片描述
    这里我用的是cil框架 vue3 下面贴代码
    组价代码:

    <template>
      <view class="page">
        <view
          v-for="(item, index) in navList"
          :key="index"
          @click="changeNav(index)"
          :class="current == index ? 'selectNav' : ''"
          >{{ item.title }}{{ item.num ? "(" + item.num + ")" : "" }}</view
        >
      </view>
    </template>
    
    <script setup lang="ts">
    import { ref, reactive, watch } from "vue";
    const emit = defineEmits(["changeNav"]);
    const props = withDefaults(
      defineProps<{
        navList: any;
        currentNav?: number;
      }>(),
      { navList: [], currentNav: 0 }
    );
    const current = ref<number>(props.currentNav);
    const changeNav = (index: number) => {
      current.value = index;
      emit("changeNav", current.value);
    };
    </script>
    
    <style lang="scss" scoped>
    .page {
      width: 100%;
      height: 88rpx;
      background-color: #fff;
      display: flex;
      align-items: center;
      justify-content: space-around;
      font-size: 30rpx;
      color: #14131f;
    }
    
    .selectNav {
      color: #00cd73;
      font-size: 34rpx;
      position: relative;
      font-weight: 600;
    }
    
    .selectNav::after {
      content: "";
      position: absolute;
      bottom: -20rpx;
      left: 0%;
      width: 90rpx;
      height: 10rpx;
      background: #00cd73;
      border-radius: 5rpx;
    }
    </style>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60

    父组件使用方法:

    <template>
      <view class="page">
        <Sectionalizer :navList="navList" @changeNav="changeNav"></Sectionalizer>
      </view>
    </template>
    <script setup lang="ts">
    import { ref, reactive } from "vue";
    import Sectionalizer from "@/components/sectionalizer.vue";
    const navList = ref<any>([
      {
        title: "未进行",
        num: 5,
      },
      {
        title: "进行中",
        num: 2,
      },
      {
        title: "已完成",
        num: 12,
      },
    ]);
    const changeNav = (index: number) => {
      console.log(index);
    };
    </script>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
  • 相关阅读:
    爬虫 — App 爬虫(一)
    敏捷开发模式下如何快速提升产品质量
    实现表格表头自定义编辑、一键导入、增加列
    OWASP TOP 10
    gradle配置文件
    xctf very_easy_sql
    一文带您了解什么是渲染农场
    Java中可以用的大数据推荐算法
    Hbase简介
    在Android studio高版本上使用低版本的Github项目库报错未能解析:Landroid/support/v4/app/FrageActivity;
  • 原文地址:https://blog.csdn.net/qq_43923146/article/details/133771031