鸿蒙 数组 用到的
·
ImageAnimator()// .images([
// { src: $r('app.media.bg1_25612') },
// { src: $r('app.media.bg2_25612') },
// { src: $r('app.media.bg3_25612') },
// { src: $r('app.media.bg4_25612') },
// { src: $r('app.media.bg5_25612') },
// ])
.images(Array.from({ length: 5 }, (item: string, index: number) => {
return { src: $r(`app.media.bg${index + 1}_25612`) } as ImageFrameInfo
}))
.unShift()数据添加到index 0
push()正常添加数据
Shift()删除第一个数据 返回被删除的
pop() 删除最后一个数据 返回被删除的
A数组添加B数组的所有 用... 这里可以,隔开

// this.playState.playList=this.songs
// 或者 先清空数组 再添加
this.playState.playList.length=0
this.playState.playList=[...this.songs]
//随机下一首 取0-10之间的整数
this.currentSong.playIndex=Math.floor(Math.random()*10)
slice(start end)截取数组 返回一个新的
更多推荐


所有评论(0)