Skip to main content
Version: v3

CYCLE_LIST

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

cycle_list_sample

Create a list that scrolls in a loop, which can be populated with images.

Create UI widget

import { createWidget, widget } from '@zos/ui'

const cycleList = createWidget(widget.CYCLE_LIST, Param)

Type

Param: object

PropertiesDescriptionRequiredType
item_bg_colorBackground color.YESnumber
item_heightThe height of item.YESnumber
xThe x-coordinate of widgets.YESnumber
yThe y-coordinate of widgets.YESnumber
wThe width of widgets.YESnumber
hThe height of widgets.YESnumber
data_arrayData arrays.YESArray<Data>
data_sizeThe length of the array.YESnumber
item_click_funcCallback for item click.NOItemClickFunc
item_focus_change_funcItem focus state callback.NOItemFocusChangeFunc

ItemClickFunc: function

(cycleList: CycleList, index: number) => void
PropertiesTypeNotes
cycleListobjectThe instance of cycleList.
indexnumberClicked item index.Starting from 0.

ItemFocusChangeFunc: function

(cycleList: CycleList, index: number, isFocus: boolean) => void
参数说明类型
cycleListThe instance of cycleList.object
indexLosing/getting the index of the focus item.number
isFocusWhether to get the focus.boolean

Code example

tip

Please refer to Design Resources for the image resources in the code example

import { createWidget, widget } from '@zos/ui'

Page({
state: {
pageName: 'CYCLE_LIST'
},

build() {
const imgArray = ['number-img/0.png', 'number-img/1.png', 'number-img/2.png', 'number-img/3.png', 'number-img/4.png']
const cycleList = createWidget(widget.CYCLE_LIST, {
x: 230,
y: 120,
h: 300,
w: 30,
data_array: imgArray,
data_size: 5,
item_height: 100,
item_click_func: (list, index) => {
console.log(index)
},
item_bg_color: 0xffffff
})
}
})