Appearance
API
方法
init(data)
初始化list-view组件,有返回值,操作返回值更新视图
参数名 | 类型 | 说明 |
---|---|---|
data | Array | 列表数据集合 |
注意: 获取基本类型数据可以直接操作返回值使用,获取引用类型数据可以通过JSON.parse(JSON.stringify(返回值))获取;
点击查看源码
js
初始化 let returnVal = this.$refs.list_view.init(data)
init返回值相关API
function | 说明 |
---|---|
push | returnVal.push({单条数据}) returnVal.push(...[多条数据]) |
pop | returnVal.pop() 末尾删除一条item |
concat | returnVal.concat() 链接returnVal数据 |
splice(1个参数) | 删除 returnVal.splice(1) 从第一项开始删除之后所有item |
splice(2个参数) | 删除 returnVal.splice(1,2) 从第1个开始 删除2条item |
splice(3个参数-替换) | returnVal.splice(4, 2, data) 从索引位置 4 开始,替换两个元素,替换的data (当三个参数第二个参数不为0时 为替换) |
splice(3个参数-插入) | returnVal.splice(4, 0, data) 从索引位置 4 开始,替换0,插入的data (当三个参数第二个参数为0时 为插入)仅支持runtime版本 2.3+ |
deleteItem | returnVal.deleteItem(id,number) //第一个参数是item的 id(初始化data中的数据必须包含id) 第二个参数是从包括id之后删除的个数 |
forEach | returnVal.forEach(el => {el.assetTitle = '修改assetTitle'}) //循环修改每个item的值 整体更新 |
scrollToTop()
列表滑动到顶部
点击查看源码
js
this.$refs.list_view.scrollToTop()
setDisplay(display)
设置列表是否显示
参数名 | 类型 | 说明 |
---|---|---|
display | Boolean | 是否显示 |
点击查看源码
js
this.$refs.list_view.setDisplay(false)
scrollToPosition(index)
滑动到指定位置
参数名 | 类型 | 说明 |
---|---|---|
index | Int | 要滑到的位置 |
点击查看源码
js
this.$refs.list_view.scrollToPosition(index)
scrollToIndex(y, anim, offsetndex)
滑动到指定位置并附带动画和偏移量
参数名 | 类型 | 说明 |
---|---|---|
y | Int | 要滑到的位置 |
anim | Boolean | 是否开启动画 |
offsetndex | Int | 偏移量 |
点击查看源码
js
this.$refs.list_view.scrollToIndex(y, anim, offsetndex)
setItemFocused(pos)
设置指定子Item获取焦点
参数名 | 类型 | 说明 |
---|---|---|
pos | Int | 子Item位置 |
点击查看源码
js
this.$refs.list_view.setItemFocused(pos)
setItemSelected(pos,b)
设置选中的子item,注意此方法只在view已经显示出来以后调用才有效
参数名 | 类型 | 说明 |
---|---|---|
pos | Int | 要选中的子View位置 |
b | Boolean | 设置要选中的子View的焦点 |
点击查看源码
js
this.$refs.list_view.setItemSelected(pos, b)
stopPage()
当在分页加载完数据时,调用该方法停止分页关闭进度条样式
点击查看源码
js
this.$refs.list_view.stopPage()
事件
@item-click
Item点击事件回调
参数名 | 类型 | 说明 |
---|---|---|
position | Int | 点击Item的位置(在子布局里) |
parentPosition | Int | 点击Item的在父布局中的位置 |
name | String | 点击Item的name类型 |
item | Object | 当前点击item绑定的数据 |
@item-focused
Item焦点事件回调
参数名 | 类型 | 说明 |
---|---|---|
position | Int | 焦点所在Item的位置(在子布局里) |
parentPosition | Int | 焦点所在Item的在父布局中的位置 |
hasFocus | Boolean | 焦点所在Item是否获得焦点 |
name | String | 点击Item的name类型 |
item | Object | 当前点击item绑定的数据 |
@item-bind
Item绑定事件回调
参数名 | 类型 | 说明 |
---|---|---|
position | Int | 绑定Item的位置 |
name | String | 绑定Item的name |
@item-unbind
Item解除绑定事件回调
参数名 | 类型 | 说明 |
---|---|---|
position | Int | 解除绑定Item的位置 |
name | String | 解除绑定Item的name |
@scroll
列表滑动onScroll事件回调
参数名 | 类型 | 说明 |
---|---|---|
contentOffset | Map | 滑动参数 |
contentOffset参数:
参数名 | 类型 | 说明 |
---|---|---|
x | Float | 列表滑动x轴偏移量 |
y | Float | 列表滑动y轴偏移量 |
@scroll-state-changed
列表滑动onScrollStateChanged事件回调
参数名 | 类型 | 说明 |
---|---|---|
contentOffset | Map | 滑动参数 |
state | Map | 滑动状态 |
contentOffset参数:
参数名 | 类型 | 说明 |
---|---|---|
x | Float | 列表滑动x轴偏移量 |
y | Float | 列表滑动y轴偏移量 |
state参数:
参数名 | 类型 | 说明 |
---|---|---|
oldState | Int | 之前列表滑动状态 |
newState | Int | 当前列表滑动状态 |
@focus-search-failed
列表寻焦失败事件回调
参数名 | 类型 | 说明 |
---|---|---|
child | Map | 当前焦点所在item |
focused | Map | 焦点将要落在item |
direction | Int | 滑动方向 |
child参数:
参数名 | 类型 | 说明 |
---|---|---|
index | Int | 当前item的位置 |
id | Int | 当前item的id |
name | String | 当前item的name |
focused参数:
参数名 | 类型 | 说明 |
---|---|---|
id | Int | 焦点将要落在item的id |
name | String | 焦点将要落在item的name |
注意事项
horizontal
、advancedFocusSearchSpan
、padding
属性不可动态改变,这三个在list-view初始化时就确定;要实现
onItemClick
和onItemFocus
回调,需要在item中加上属性eventClick
和eventFocus
,这样才能让item响应点击和焦点事件;:scrollThresholdHorizontal
和:scrollThresholdVertical
属性的生效条件是:makeChildVisibleType='center'
;