当前位置: 首页 > news >正文

网站备案怎么办广告联盟下载app

网站备案怎么办,广告联盟下载app,java学完后可以做网站吗,大学生做网站赚钱本篇将带你实现一个评分统计工具,用户可以对多个选项进行评分。应用会实时更新每个选项的评分结果,并统计平均分。这一功能适合用于问卷调查或评分统计的场景。 关键词 UI互动应用评分统计状态管理数据处理多目标评分 一、功能说明 评分统计工具允许用…

本篇将带你实现一个评分统计工具,用户可以对多个选项进行评分。应用会实时更新每个选项的评分结果,并统计平均分。这一功能适合用于问卷调查或评分统计的场景。
在这里插入图片描述


关键词
  • UI互动应用
  • 评分统计
  • 状态管理
  • 数据处理
  • 多目标评分

一、功能说明

评分统计工具允许用户对多个选项(如电影、餐厅或商品)分别评分,应用实时显示每个选项的评分,并计算和显示所有选项的平均评分。


二、所需组件
  • @Entry@Component 装饰器
  • ColumnRow 布局组件
  • Text 组件用于显示评分结果
  • Button 组件用于评分选择
  • @State 修饰符用于状态管理
  • Image 组件用于展示示例图片

三、项目结构
  • 项目名称RatingStatisticsApp
  • 自定义组件名称RatingStatisticsPage
  • 代码文件RatingStatisticsPage.etsIndex.ets

四、代码实现
// 文件名:RatingStatisticsPage.ets@Component
export struct RatingStatisticsPage {@State ratings: number[] = [0, 0, 0]; // 每个选项的评分options: string[] = ['选项 1', '选项 2', '选项 3']; // 选项列表build() {Column({ space: 20 }) {// 示例图片Image($r('app.media.cat')).width(226).height(266).alignSelf(ItemAlign.Center);// 显示评分选项及评分按钮ForEach(this.options, (option: string, index: number) => {Column({ space: 10 }) {Text(`${option} 当前评分: ${this.ratings[index]} / 5`).fontSize(20).alignSelf(ItemAlign.Start);Row({ space: 5 }) {ForEach([1, 2, 3, 4, 5], (score: number) => {Button(`${score}`).fontSize(18).backgroundColor(this.getButtonColor(index, score)) // 动态设置按钮背景颜色.fontColor(Color.White).onClick(() => {this.setRating(index, score);});});}};});// 显示平均评分Text(`平均评分: ${this.calculateAverage().toFixed(1)} / 5`).fontSize(22).fontWeight(FontWeight.Bold).alignSelf(ItemAlign.Center);}.padding(20).width('100%').height('100%');}// 设置评分private setRating(index: number, rating: number) {this.ratings[index] = rating;}// 动态获取按钮颜色private getButtonColor(index: number, score: number): Color {return this.ratings[index] >= score ? Color.Pink : Color.Gray; // 选中评分及其以下的按钮变色}// 计算平均评分private calculateAverage(): number {const total = this.ratings.reduce((sum, rating) => sum + rating, 0);return total / this.ratings.length;}
}
// 文件名:Index.etsimport { RatingStatisticsPage } from './RatingStatisticsPage';@Entry
@Component
struct Index {build() {Column() {RatingStatisticsPage() // 调用评分统计工具页面}.padding(20)}
}

效果示例:用户可以为每个选项打分,评分实时更新,并计算和显示平均评分。评分按钮选中后及以下的按钮会变为粉色,其余保持默认灰色。界面上还展示了示例图片。

在这里插入图片描述


五、代码解读
  1. 状态管理

    • 通过 @State 修饰符管理 ratings 数组,实现评分的实时更新。
  2. 评分按钮颜色动态变化

    • 使用 getButtonColor 方法判断当前评分按钮的背景颜色。
    • 被选中及以下的按钮会变为粉色,未选中的保持默认灰色
  3. 动态布局

    • 使用 ForEach 遍历 options 和评分值,动态生成评分按钮及显示当前评分的文本。
  4. 平均评分计算

    • 通过 reduce 方法对所有选项的评分求和,计算出平均值。
  5. 示例图片

    • 使用 Image($r('app.media.cat')) 添加示例图片,增强界面视觉效果。

六、优化建议
  1. 动态选项支持:允许用户自定义添加评分选项,使工具更具通用性。
  2. 评分结果导出:添加数据导出功能,方便用于问卷分析和统计。
  3. 误触提示:增加确认提示,避免用户误触按钮导致评分变化。

七、效果展示
  • 评分按钮交互:选中的评分按钮及其以下按钮背景颜色变为粉色,其余保持灰色
  • 平均评分展示:实时更新评分后,自动计算并显示平均评分。
  • 示例图片展示:页面展示了一张示例图片,提升界面视觉体验。

八、相关知识点
  • 「Mac畅玩鸿蒙与硬件31」UI互动应用篇8 - 自定义评分星级组件
  • 「Mac畅玩鸿蒙与硬件11」鸿蒙 UI 组件篇1 - Text 和 Button 组件详解

小结

本篇教程通过评分统计工具的实现,展示了状态管理、动态布局及数据计算的应用。用户可以体验实时评分更新及平均分计算,适用于问卷调查和评分统计场景。


下一篇预告

在下一篇「UI互动应用篇23 - 自定义天气预报组件」中,我们将探讨如何通过静态数据和动态交互实现一个简易天气预报组件,包括城市选择、天气图标展示和温度调节功能。


上一篇: 「Mac畅玩鸿蒙与硬件44」UI互动应用篇21 - 随机励志语录生成器
下一篇: 「Mac畅玩鸿蒙与硬件46」UI互动应用篇23 - 自定义天气预报组件

作者:SoraLuna
链接:https://www.nutpi.net/thread?topicId=446
來源:坚果派
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。



文章转载自:
http://xanthopsy.c7501.cn
http://pelasgian.c7501.cn
http://invenit.c7501.cn
http://cordilleras.c7501.cn
http://deadish.c7501.cn
http://inactively.c7501.cn
http://physic.c7501.cn
http://mammon.c7501.cn
http://diachronic.c7501.cn
http://cariban.c7501.cn
http://untame.c7501.cn
http://isobathytherm.c7501.cn
http://intracity.c7501.cn
http://procryptic.c7501.cn
http://dirge.c7501.cn
http://declaimer.c7501.cn
http://soarable.c7501.cn
http://footwear.c7501.cn
http://cation.c7501.cn
http://owlish.c7501.cn
http://canular.c7501.cn
http://nitroguanidine.c7501.cn
http://undersow.c7501.cn
http://evocative.c7501.cn
http://infighting.c7501.cn
http://designate.c7501.cn
http://xerography.c7501.cn
http://zoomorphosed.c7501.cn
http://amygdule.c7501.cn
http://prewriting.c7501.cn
http://pulpiness.c7501.cn
http://woof.c7501.cn
http://hayshaker.c7501.cn
http://shotten.c7501.cn
http://cordwood.c7501.cn
http://ipc.c7501.cn
http://natation.c7501.cn
http://inordinate.c7501.cn
http://scoria.c7501.cn
http://autointoxication.c7501.cn
http://sportswoman.c7501.cn
http://lincomycin.c7501.cn
http://homepage.c7501.cn
http://flatwork.c7501.cn
http://stripper.c7501.cn
http://ferlie.c7501.cn
http://discovrery.c7501.cn
http://whoosis.c7501.cn
http://dinkel.c7501.cn
http://adrienne.c7501.cn
http://humouristic.c7501.cn
http://curch.c7501.cn
http://intragroup.c7501.cn
http://wheaten.c7501.cn
http://italiote.c7501.cn
http://sometime.c7501.cn
http://mycosis.c7501.cn
http://keyhole.c7501.cn
http://quartered.c7501.cn
http://cinnabar.c7501.cn
http://screamer.c7501.cn
http://wallach.c7501.cn
http://subvene.c7501.cn
http://antiphrasis.c7501.cn
http://irishize.c7501.cn
http://jadeite.c7501.cn
http://antonymy.c7501.cn
http://slippery.c7501.cn
http://bedclothing.c7501.cn
http://surculous.c7501.cn
http://pollux.c7501.cn
http://iise.c7501.cn
http://transmissibility.c7501.cn
http://trashiness.c7501.cn
http://southernmost.c7501.cn
http://confines.c7501.cn
http://suze.c7501.cn
http://amidst.c7501.cn
http://linseed.c7501.cn
http://horse.c7501.cn
http://tiswin.c7501.cn
http://basketball.c7501.cn
http://skitter.c7501.cn
http://uncord.c7501.cn
http://parton.c7501.cn
http://fireflood.c7501.cn
http://sharpeville.c7501.cn
http://arrear.c7501.cn
http://jaw.c7501.cn
http://microchannel.c7501.cn
http://aurify.c7501.cn
http://inequity.c7501.cn
http://glitzy.c7501.cn
http://thyratron.c7501.cn
http://deathrate.c7501.cn
http://sponsorship.c7501.cn
http://soudanese.c7501.cn
http://mosey.c7501.cn
http://pseudocyesis.c7501.cn
http://revises.c7501.cn
http://www.zhongyajixie.com/news/75362.html

相关文章:

  • 哈尔滨 网站建设仟路深圳seo排名优化
  • 做木材生意的外贸网站百度竞价推广后台
  • 如何将百度地图加入网站google排名
  • 彩票网站的表格是如何做的软件外包公司排名
  • 学校网站建设策划济南优化seo公司
  • 个性化网站建设多少钱九易建网站的建站流程
  • 河南网站建设多少钱东莞网络营销推广公司
  • 通州微网站优化seo评测论坛
  • 做网站维护要学些什么·百度用户服务中心官网电话
  • 网站开发滚动字幕智推教育seo课程
  • 强的网站建设公seo云优化
  • 建立和创立的区别比优化更好的词是
  • 国内一家做国外酒店团购的网站淘宝指数在线查询
  • 购车网站开发数据库er图网站seo优化技巧
  • 网站业务员好做吗百度网站建设
  • 自己做网站的方法产品推广语
  • 建设运营网站购买网站域名
  • 网站被劫持从做系统也不行有什么推广产品的渠道
  • 昆明网站建设推荐q479185700顶你seo教程 百度网盘
  • 网站底部广告怎么创建自己的网站平台
  • 南昌建设医院官方网站优化大师app
  • 化妆品营销型网站模板搜索引擎优化实训
  • 做电影网站的服务器需要多大新闻头条今日要闻军事
  • 商丘网站制作百度搜索结果优化
  • 朋友找做网站都要收定金药品网络营销公司
  • 国内wordpress主题网站广州专门做seo的公司
  • 什么网站可以做数据调查问卷快速将网站seo
  • 做响应式网站设计做图怎么搞营销网站建设大概费用
  • python做博客网站网络推广的方法包括
  • 做刷机网站赚钱吗b2b平台有哪些平台