uView2.0 ScrollList 多菜单扩展

ScrollList 多菜单扩展

使用uni/vue2

 // HTML
<u-scroll-list><view class="scroll-list margin-top-xs"><!-- 第一行 --><view class="scroll-list__row"><viewclass="scroll-list__goods-item"style="width: 248rpx;height:120rpx;display:flex;justify-content: center;align-items:center"v-for="(item, index) in list.slice(0, 6)" :key="'row1-' + index":class="[(index === 4) && 'scroll-list__goods-item--no-margin-right']"><text>{{item.name}}</text><text class="margin-top-sm text-bold" style="color:#ff6347">¥{{ item.price }}</text></view></view><!-- 第二行 --><view class="scroll-list__row"><viewclass="scroll-list__goods-item"style="width: 248rpx;height:120rpx;display:flex;justify-content: center;align-items:center"v-for="(item, index) in list.slice(6, 12)" :key="'row2-' + index":class="[(index === 4) && 'scroll-list__goods-item--no-margin-right']"><text>{{item.name}}</text><text class="margin-top-sm text-bold" style="color:#ff6347">¥{{ item.price }}</text></view></view></view></u-scroll-list>
// JS
data() {return {list: [{name: '全部销售额',price: 11.90},{name: '全部单数', price: 11.90},{name: '预估佣金', price: 11.90},{name: '退款销售额', price: 11.90},{name: '退款订单',price: 11.90},{name: '退款服务费',price: 11.90},{name: '有效销售额',price: 11.90},{name: '有效单数',price: 11.90},{name: '有效佣金',price: 11.90},{name: '已结算销售额',price: 11.90},{name: '已结算订单',price: 11.90},{name: '已结算服务费',price: 11.90},],}}
// css
<style lang="scss">.scroll-list {display: flex;flex-direction: column;.scroll-list__row {display: flex;flex-direction: row;margin-top:5rpx;}.scroll-list__goods-item {display: flex;flex-direction: column;align-items: center;}
}<style>

如果下面的指示器跟上面的滑动不同步的情况下用下面的代码

<template><u-scroll-list @scroll="handleScroll"><view class="scroll-list margin-top-xs" ref="scrollList"><!-- 第一行 --><view class="scroll-list__row"><viewclass="scroll-list__goods-item"style="width: 248rpx;height:120rpx;display:flex;justify-content: center;align-items:center"v-for="(item, index) in list.slice(0, 6)" :key="'row1-' + index":class="[(index === 4) && 'scroll-list__goods-item--no-margin-right']"><text>{{item.name}}</text><text class="margin-top-sm text-bold" style="color:#ff6347">{{ item.price }}</text></view></view><!-- 第二行 --><view class="scroll-list__row"><viewclass="scroll-list__goods-item"style="width: 248rpx;height:120rpx;display:flex;justify-content: center;align-items:center"v-for="(item, index) in list.slice(6, 12)" :key="'row2-' + index":class="[(index === 4) && 'scroll-list__goods-item--no-margin-right']"><text>{{item.name}}</text><text class="margin-top-sm text-bold" style="color:#ff6347">{{ item.price }}</text></view></view></view><div class="indicator-container"><div class="indicator" :style="{ width: indicatorWidth + '%' }"></div></div></u-scroll-list>
</template><script>
export default {data() {return {list: [{name: '全部销售额',price: 11.90},{name: '全部单数', price: 11.90},{name: '预估佣金', price: 11.90},{name: '退款销售额', price: 11.90},{name: '退款订单',price: 11.90},{name: '退款服务费',price: 11.90},{name: '有效销售额',price: 11.90},{name: '有效单数',price: 11.90},{name: '有效佣金',price: 11.90},{name: '已结算销售额',price: 11.90},{name: '已结算订单',price: 11.90},{name: '已结算服务费',price: 11.90},],indicatorWidth: 0,totalScrollableWidth: 0,};},mounted() {this.calculateScrollableWidth();uni.onWindowResize(this.calculateScrollableWidth);},beforeDestroy() {uni.offWindowResize(this.calculateScrollableWidth);},methods: {calculateScrollableWidth() {this.$nextTick(() => {const query = uni.createSelectorQuery().in(this);query.select('.scroll-list').boundingClientRect((data) => {if (data) {this.totalScrollableWidth = data.scrollWidth - data.width;}}).exec();});},handleScroll(event) {const scrollLeft = event.detail.scrollLeft;if (this.totalScrollableWidth > 0) {this.indicatorWidth = (scrollLeft / this.totalScrollableWidth) * 100;} else {this.indicatorWidth = 0;}},},
};
</script><style>
.scroll-list {display: flex;flex-direction: column;overflow-x: auto;
}.scroll-list__row {display: flex;flex-direction: row;margin-top: 5rpx;
}.scroll-list__goods-item {display: flex;flex-direction: column;align-items: center;
}.indicator-container {position: relative;height: 4px;background-color: #e0e0e0;margin-top: 10px;
}.indicator {position: absolute;height: 100%;background-color: #ff6347;transition: width 0.3s;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/32150.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Apple - Secure Coding Guide

本文翻译整理自&#xff1a;Secure Coding Guide https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Introduction.html#//apple_ref/doc/uid/TP40002477-SW1 文章目录 一、安全编码指南简介1、概览黑客和攻击者没有平台是免疫…

【办公类-50-01】20240620自主游戏观察记录表19周内容打乱

背景需求&#xff1a; 又到了期末&#xff0c;各种班级资料需要提交。 有一份自主游戏观察记录需要写19周&#xff08;每周2次&#xff09;的观察记录&#xff0c;并根据参考书填写一级、三级、五级的评价指标。 去年中六班的时候&#xff0c;我很认真的手写了21周的户外游戏…

算法第八天:leetcode 35.搜索插入位置

一、搜索插入位置 该题的题目链接如下所示&#xff0c;看题解前先点击或复制下面链接进入力扣做题哦&#xff0c;做题后看会更好哦。 https://leetcode.cn/problems/search-insert-position/ 给定一个排序数组和一个目标值&#xff0c;在数组中找到目标值&#xff0c;并返…

具有 Hudi、MinIO 和 HMS 的现代数据湖

Apache Hudi 已成为管理现代数据湖的领先开放表格式之一&#xff0c;直接在现代数据湖中提供核心仓库和数据库功能。这在很大程度上要归功于 Hudi 提供了表、事务、更新/删除、高级索引、流式摄取服务、数据聚类/压缩优化和并发控制等高级功能。 我们已经探讨了 MinIO 和 Hudi…

MySQL Binary Log

显示系统变量&#xff1a;二进制日志 -- 显示系统变量&#xff1a;二进制日志 show variables like %log_bin%;显示二进制日志文件列表 -- 显示二进制日志文件列表 show binary logs;显示二进制日志事件 -- 显示二进制日志事件 show binlog events [in log_name] [from pos]…

Vue3 - 在项目中使用vue-i18n不生效的问题

检查和配置 Vue I18n 确保你已经正确安装了Vue I18n并且配置了组合API模式。 安装 Vue I18n npm install vue-i18nnext配置 i18n.js import { createI18n } from vue-i18n; import messages from ./messages;const i18n createI18n({legacy: false, // 使用组合 API 模式l…

Linux检查端口nmap

yum install -y nmap # 查看本机在运行的服务的端口号 nmap 127.0.0.1 补充&#xff1a;netstat netstat -tunlp | grep 3306

android怎么知道FileProvider应该导入的包名是什么?androidx.core.content.FileProvider

在Android中&#xff0c;FileProvider是一个特殊的ContentProvider&#xff0c;它允许你安全地与其他应用共享文件。FileProvider通常用于通过Intent发送文件&#xff08;如通过ACTION_SEND&#xff09;或用于在应用中访问文件而不需要使用FILE URI模式&#xff0c;因为FILE UR…

【Qt】模态对话框和非模态对话框

1. 介绍 模态对话框&#xff1a; 显示的对话框不允许鼠标再去点击其他窗口&#xff0c;直到对话框退出。非模态对话框&#xff1a; 显示的对话框在现实后继续运行主程序&#xff0c;还可以在主窗口上操作&#xff0c;主窗口和非模态对话框之间可以交互控制&#xff0c;典型的例…

读《文明之光》第2册总结

《文明之光》系列大致按照从地球诞生到近现代的顺序讲述了人类文明进程的各个阶段&#xff0c;每个章节相对独立&#xff0c;全景式地展现了人类文明发展历程中的多样性。《文明之光》系列第二册讲述了从近代科学兴起&#xff0c;到工业革命时代&#xff0c;以及原子能应用这一…

C++/Qt 小知识记录7

工作中遇到的一些小问题&#xff0c;总结的小知识记录&#xff1a;C/Qt 小知识7 编译FFMPEG遇到的问题CMakeLists.txt配置FFMPEG的依赖方式&#xff1a; x264在Windows下编译生成*.libVS编译Qt工程时&#xff0c;遇到提示Change Qt Version的情况在QtOsg的窗口上嵌入子窗口&…

基于JSP的交通事故档案管理系统

开头语&#xff1a;你好&#xff0c;我是计算机学长猫哥&#xff0c;如果你对系统有更多的期待或建议&#xff0c;欢迎随时联系我。 开发语言&#xff1a;Java 数据库&#xff1a;MySQL 技术&#xff1a;JSPJava 工具&#xff1a;ECLIPSE、Tomcat 系统展示 首页 管理员界…

车辆数据的提取、定位和融合(其一 共十二篇)

第一篇&#xff1a; System Introduction 第二篇&#xff1a;State of the Art 第三篇&#xff1a;localization 第四篇&#xff1a;Submapping and temporal weighting 第五篇&#xff1a;Mapping of Point-shaped landmark data 第六篇&#xff1a;Clustering of landma…

Dockerfile实战

Dockerfile是用来快速创建自定义镜像的一种文本格式的配置文件&#xff0c;在持续集成和持续部署时&#xff0c;需要使用Dockerfile生成相关应用程序的镜像。 Dockerfile常用命令 FROM&#xff1a;继承基础镜像MAINTAINER&#xff1a;镜像制作作者的信息&#xff0c;已弃用&a…

文件管理—linux(基础IO)

目录 ​编辑 一、C语言文件接口&#xff08;库函数&#xff09; hello.c写文件 hello.c读文件 输出信息到显示器 stdin & stdout & stderr 二、系统文件I/O&#xff08;系统调用&#xff09; hello.c 写文件&#xff1a; hello.c读文件 接口介绍 open open…

JetBrains PhpStorm 2024 mac/win版:探索PHP之美,智慧编程新境界

JetBrains PhpStorm 2024是一款卓越的PHP集成开发环境(IDE)&#xff0c;专为满足现代PHP开发者的需求而精心打造。它凭借强大的功能和出色的性能&#xff0c;赢得了全球开发者的广泛赞誉。 PhpStorm 2024 mac/win版获取 PhpStorm 2024提供了智能的代码编辑功能&#xff0c;包括…

【TKGQA】关于时间知识图谱问答的一篇综述阅读

前言 时间知识图谱问答&#xff08;TKGQA&#xff09;是KBQA中一个关注时间问题的重要子任务。时间问题包含时间约束、需要时间标记的答案&#xff0c;反映了现实世界事件的动态和演变性质。 一、TKGQA 1.1 概述 时间知识图谱&#xff08;TKG&#xff09;&#xff1a; 通常表…

vcpkg安装g2o,提示找不到cs.h,debug模式运行提示找不到libcxsparse.dll

1 找不到cs.h 在VS中双击错误提示&#xff0c;定位到csparse_extension.h文件&#xff0c;将 #include<cs.h>修改为 // #include<cs.h> #include <suitesparse/cs.h>即可正常编译 2 debug模式找不到libcxsparse.dll 我这边直接使用RelWithDebug模式&…

代码随想录算法训练营Day22|235. 二叉搜索树的最近公共祖先 ,701.二叉搜索树中的插入操作 ,450.删除二叉搜索树中的节点

235. 二叉搜索树的最近公共祖先&#xff1a;代码随想录 这道题目的意思和前面的二叉树的最近公共祖先一样&#xff0c;只不过是换成了二叉搜索树&#xff0c;我采用的方法还是和普通二叉树一样&#xff0c;利用回溯的方法&#xff0c;来看具体代码的实现 class Solution { publ…

Android 添加自己的时钟小部件

小部件&#xff0c;也叫微件&#xff0c; 它的介绍参考官网 应用 widget 概览 https://developer.android.google.cn/develop/ui/views/appwidgets/overview?hlzh-cn 直接上图&#xff0c;原生系统上&#xff0c;时钟应用的小部件效果。 我也整一个。 1.创建小部件布局文…