当前位置: 首页 > news >正文

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

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

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

<template><view class="page"><viewv-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>

父组件使用方法:

<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>
http://www.lryc.cn/news/190047.html

相关文章:

  • 文心一言 VS 讯飞星火 VS chatgpt (111)-- 算法导论10.2 2题
  • 小程序中使用echarts的相关配置以及折线图案例(简单易懂)
  • 前端面试回答不好的问题总结
  • 漏洞预警|CVE-2023-38545 Curl 和 libcurl 堆缓冲区溢出漏洞
  • 【Java 进阶篇】HTML 语义化标签详解
  • 【思维构造】Element Extermination—CF1375C
  • CSP模拟53联测15 D. 子序列
  • iceberg-flink 十一:在dlink代码中建表增加catalog地址。
  • 多列等高实现
  • 2023 泰山杯 --- Crypto wp
  • 蓝桥杯每日一题20233.10.10
  • 366. 寻找⼆叉树的叶⼦节点
  • python - excel 设置样式
  • Gemmini测试test文件chisel源码详解(一)
  • RabbitMQ中的手动应答和自动应答
  • 【C语言】文件的操作与文件函数的使用(详细讲解)
  • ROS-PX4仿真笔记_1
  • 使用 Python 中的小波变换信号驾驭股票价格的波动
  • AndroidStudio模拟器,没有Google Play的就有ROOT权限
  • 复选框 前端代码
  • 每日一练 | 网络工程师软考真题Day41
  • vue使用pinia存储数据并保持数据持久化
  • k8s - Flannel
  • 服务器中了balckhoues勒索病毒怎么办?勒索病毒解密,数据恢复
  • react-pdf | Warning: TextLayer styles not found.
  • vue上传文件MD5加密
  • vue2 .sync 修饰符
  • 使用Tensorrt的一般步骤
  • uniapp apple 苹果登录 离线本地打包
  • 【数据库】Sql Server数据迁移,处理自增字段赋值