OpenHarmony进度条提升用户体验的实用指南
一 选对进度条类型与语义
二 关键 API 与最小可用示例
@Entry
@Component
struct LinearProgressDemo {
@State progress: number = 0
build() {
Column({ space: 12 }) {
Text(`进度:${this.progress}%`)
Progress({ value: this.progress, total: 100, type: ProgressType.Linear })
.width('100%')
.height(8)
.backgroundColor('#E0E0E0')
.color('#1890FF')
}
.padding(16)
.onAppear(() => {
// 模拟任务进度
let timer = setInterval(() => {
this.progress = Math.min(this.progress + 5, 100)
if (this.progress >= 100) clearInterval(timer)
}, 200)
})
}
}
@Entry
@Component
struct LoadingDemo {
@State loading: boolean = true
build() {
Column({ space: 12 }) {
if (this.loading) {
LoadingProgress()
.width(50)
.height(50)
.color('#1890FF')
Text('加载中...')
.fontSize(14)
.fontColor('#666666')
} else {
Text('完成')
}
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.onAppear(() => {
setTimeout(() => (this.loading = false), 3000)
})
}
}
三 交互与反馈设计要点
四 多设备与性能优化
五 进阶用法与常见坑
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。