中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
本文原创发布在华为开发者社区。
本示例基于XComponent组件实现了上下滑动视频浏览效果,同时提供了另一种XComponent组件实现的上下滑动视频浏览效果,用于与XComponent组件案例对比。
基于XComponent滑动功能源码链接
运行项目前,请执行 ohpm install @ohos/hamock,下载hamock依赖。
Swiper() { ForEach(this.videoValue, (item: string) => { PlayVideo({ item: item }) }, (item: string) => item) } .index(1) .vertical(true) .indicator(false) .loop(true) .align(Alignment.Center)
XComponent({ id: 'xcomponentId-container', type: 'component' }) { addText(this.message) Divider() .margin(4) .strokeWidth(2) .color('#F1F3F5') .width('80%') Column() { Swiper() { ForEach(this.videoValue, (item: string) => { PlayVideo({ item: item }) }, (item: string) => item) } .index(1) .vertical(true) .indicator(false) .loop(true) .align(Alignment.Center) }.height('100%') .backgroundColor(Color.Black) }
微信扫码分享