uView ScrollList 横向滚动列表

2024-03-13 16:28

本文主要是介绍uView ScrollList 横向滚动列表,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

该组件一般用于同时展示多个商品、分类的场景,也可以完成左右滑动的列表。

#平台差异说明

App(vue)App(nvue)H5小程序

#基本使用

通过slot传入内容

<template><u-scroll-list><view v-for="(item, index) in list" :key="index"><image :src="item.thumb"></image></view></u-scroll-list>
</template><script>export default {data() {return {list: [{thumb: "https://cdn.uviewui.com/uview/goods/1.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/2.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/3.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/4.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/5.jpg"}]}}}
</script>

copy

#指示器的使用

  • indicator 用于控制指示器是否显示
  • indicatorWidth 用于控制指示器整体的宽度
  • indicatorBarWidth 用于控制指示器滑块的宽度
  • indicatorColor 指示器的颜色
  • indicatorActiveColor 滑块的颜色
  • indicatorStyle 指示器的位置/样式控制
<template><u-scroll-list :indicator="indicator" indicatorColor="#fff0f0" indicatorActiveColor="#f56c6c"><view v-for="(item, index) in list" :key="index"><image :src="item.thumb"></image></view></u-scroll-list>
</template><script>export default {data() {return {indicator: true,list: [{thumb: "https://cdn.uviewui.com/uview/goods/1.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/2.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/3.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/4.jpg"}, {thumb: "https://cdn.uviewui.com/uview/goods/5.jpg"}]}}}
</script>

copy

#兼容性与性能

  • 此组件是在nvue中引入bindingx,此库类似于微信小程序wxs,目的是让js运行在视图层,减少视图层和逻辑层的通信折损,在nvue中会有更好的体验。
  • 此组件是在APP-VUE、H5、小程序中使用的是wxs。
  • 其他平台则使用js完成。

当滑动到最左边/最右边时,uView提供了事件leftright可供调用,用于对列表滑动到端点处的业务实现。

<template><u-scroll-list @right="right" @left="left"><view class="scroll-list" style="flex-direction: row;"><viewclass="scroll-list__goods-item"v-for="(item, index) in list":key="index":class="[(index === 9) && 'scroll-list__goods-item--no-margin-right']"><image class="scroll-list__goods-item__image" :src="item.thumb"></image><text class="scroll-list__goods-item__text">¥{{ item.price }}</text></view><view class="scroll-list__show-more"><text class="scroll-list__show-more__text">查看更多</text><u-icon name="arrow-leftward" color="#f56c6c" size="12"></u-icon></view></view></u-scroll-list>
</template>
<script>
export default {data() {return {list: [{price: '230.5',thumb: 'https://cdn.uviewui.com/uview/goods/1.jpg'}, {price: '74.1',thumb: 'https://cdn.uviewui.com/uview/goods/2.jpg'}, {price: '8457',thumb: 'https://cdn.uviewui.com/uview/goods/6.jpg'}, {price: '1442',thumb: 'https://cdn.uviewui.com/uview/goods/5.jpg'}, {price: '541',thumb: 'https://cdn.uviewui.com/uview/goods/2.jpg'}, {price: '234',thumb: 'https://cdn.uviewui.com/uview/goods/3.jpg'}, {price: '562',thumb: 'https://cdn.uviewui.com/uview/goods/4.jpg'}, {price: '251.5',thumb: 'https://cdn.uviewui.com/uview/goods/1.jpg'}]}},methods: {left() {console.log('left');},right() {console.log('right');}}
}
</script><style lang="scss">
.scroll-list {@include flex(column);&__goods-item {margin-right: 20px;&__image {width: 60px;height: 60px;border-radius: 4px;}&__text {color: #f56c6c;text-align: center;font-size: 12px;margin-top: 5px;}}&__show-more {background-color: #fff0f0;border-radius: 3px;padding: 3px 6px;@include flex(column);align-items: center;&__text {font-size: 12px;width: 12px;color: #f56c6c;line-height: 16px;}}
}
</style>

这篇关于uView ScrollList 横向滚动列表的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/805472

相关文章

MySQL 横向衍生表(Lateral Derived Tables)的实现

《MySQL横向衍生表(LateralDerivedTables)的实现》横向衍生表适用于在需要通过子查询获取中间结果集的场景,相对于普通衍生表,横向衍生表可以引用在其之前出现过的表名,本文就来... 目录一、横向衍生表用法示例1.1 用法示例1.2 使用建议前面我们介绍过mysql中的衍生表(From子句

html 滚动条滚动过快会留下边框线的解决方案

《html滚动条滚动过快会留下边框线的解决方案》:本文主要介绍了html滚动条滚动过快会留下边框线的解决方案,解决方法很简单,详细内容请阅读本文,希望能对你有所帮助... 滚动条滚动过快时,会留下边框线但其实大部分时候是这样的,没有多出边框线的滚动条滚动过快时留下边框线的问题通常与滚动条样式和滚动行

Python中合并列表(list)的六种方法小结

《Python中合并列表(list)的六种方法小结》本文主要介绍了Python中合并列表(list)的六种方法小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋... 目录一、直接用 + 合并列表二、用 extend() js方法三、用 zip() 函数交叉合并四、用

Spring Boot中的YML配置列表及应用小结

《SpringBoot中的YML配置列表及应用小结》在SpringBoot中使用YAML进行列表的配置不仅简洁明了,还能提高代码的可读性和可维护性,:本文主要介绍SpringBoot中的YML配... 目录YAML列表的基础语法在Spring Boot中的应用从YAML读取列表列表中的复杂对象其他注意事项总

uniapp小程序中实现无缝衔接滚动效果代码示例

《uniapp小程序中实现无缝衔接滚动效果代码示例》:本文主要介绍uniapp小程序中实现无缝衔接滚动效果的相关资料,该方法可以实现滚动内容中字的不同的颜色更改,并且可以根据需要进行艺术化更改和自... 组件滚动通知只能实现简单的滚动效果,不能实现滚动内容中的字进行不同颜色的更改,下面实现一个无缝衔接的滚动

C++类和对象之初始化列表的使用方式

《C++类和对象之初始化列表的使用方式》:本文主要介绍C++类和对象之初始化列表的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C++初始化列表详解:性能优化与正确实践什么是初始化列表?初始化列表的三大核心作用1. 性能优化:避免不必要的赋值操作2. 强

Python列表去重的4种核心方法与实战指南详解

《Python列表去重的4种核心方法与实战指南详解》在Python开发中,处理列表数据时经常需要去除重复元素,本文将详细介绍4种最实用的列表去重方法,有需要的小伙伴可以根据自己的需要进行选择... 目录方法1:集合(set)去重法(最快速)方法2:顺序遍历法(保持顺序)方法3:副本删除法(原地修改)方法4:

Python中DataFrame转列表的最全指南

《Python中DataFrame转列表的最全指南》在Python数据分析中,Pandas的DataFrame是最常用的数据结构之一,本文将为你详解5种主流DataFrame转换为列表的方法,大家可以... 目录引言一、基础转换方法解析1. tolist()直接转换法2. values.tolist()矩阵

Android App安装列表获取方法(实践方案)

《AndroidApp安装列表获取方法(实践方案)》文章介绍了Android11及以上版本获取应用列表的方案调整,包括权限配置、白名单配置和action配置三种方式,并提供了相应的Java和Kotl... 目录前言实现方案         方案概述一、 androidManifest 三种配置方式

python展开嵌套列表的多种方法

《python展开嵌套列表的多种方法》本文主要介绍了python展开嵌套列表的多种方法,包括for循环、列表推导式和sum函数三种方法,具有一定的参考价值,感兴趣的可以了解一下... 目录一、嵌套列表格式二、嵌套列表展开方法(一)for循环(1)for循环+append()(2)for循环+pyPhWiFd