IT评测·应用市场-qidao123.com

标题: 【05】鸿蒙实战应用开辟-点击事件测试-arkui常用组件进度条 (Progress)按钮 [打印本页]

作者: 拉不拉稀肚拉稀    时间: 2025-3-15 00:12
标题: 【05】鸿蒙实战应用开辟-点击事件测试-arkui常用组件进度条 (Progress)按钮
【05】鸿蒙实战应用开辟-点击事件测试-arkui常用组件进度条 (Progress)按钮 (Button)显示图片 (Image)切换按钮 (Toggle)单选框 (Radio)测试-全过程实战项目分享-从零开辟到上线-优雅草卓伊凡

章节设定

点击事件测试-arkui常用组件进度条 (Progress)按钮 (Button)显示图片 (Image)切换按钮 (Toggle)单选框 (Radio)测试
开辟背景

没有背景,预备活动,现在是
实战开始

调试换previewer调试



开辟前我们调试可以使用previewer调试,这个不是真机模拟器,有区别,真机很占内存,必要团体调试的时间用到比较好,


看也能很好的打开


在华为应用开辟过程中,真机调试和 Previewer 调试是两种常用的调试方式,它们各自有不同的特点,以下为你具体先容两者的区别:
运行情况


调试功能





调试效率


调试成本


如今我们对常用组件来测试下,现在卓伊凡看了官方文档这些组件应该会比较常用,因此我们实验

点击事件测试

我们写一个点击事件
  1. // xxx.ets
  2. @Entry
  3. @Component
  4. struct ButtonCase1 {
  5.   pathStack: NavPathStack = new NavPathStack();
  6.   @Builder
  7.   PageMap(name: string) {
  8.     if (name === "first_page") {
  9.       pageOneTmp()
  10.     } else if (name === "second_page") {
  11.       pageTwoTmp()
  12.     } else if (name === "third_page") {
  13.       pageThreeTmp()
  14.     }
  15.   }
  16.   build() {
  17.     Navigation(this.pathStack) {
  18.       List({ space: 4 }) {
  19.         ListItem() {
  20.           Button("First").onClick(() => {
  21.             this.pathStack.pushPath({ name: "first_page"})
  22.           })
  23.             .width('100%')
  24.         }
  25.         ListItem() {
  26.           Button("Second").onClick(() => {
  27.             this.pathStack.pushPath({ name: "second_page"})
  28.           })
  29.             .width('100%')
  30.         }
  31.         ListItem() {
  32.           Button("Third").onClick(() => {
  33.             this.pathStack.pushPath({ name: "third_page"})
  34.           })
  35.             .width('100%')
  36.         }
  37.       }
  38.       .listDirection(Axis.Vertical)
  39.       .backgroundColor(0xDCDCDC).padding(20)
  40.     }
  41.     .mode(NavigationMode.Stack)
  42.     .navDestination(this.PageMap)
  43.   }
  44. }
  45. // pageOne
  46. @Component
  47. export struct pageOneTmp {
  48.   pathStack: NavPathStack = new NavPathStack();
  49.   build() {
  50.     NavDestination() {
  51.       Column() {
  52.         Text("first_page")
  53.       }.width('100%').height('100%')
  54.     }.title("pageOne")
  55.     .onBackPressed(() => {
  56.       const popDestinationInfo = this.pathStack.pop() // 弹出路由栈栈顶元素
  57.       console.log('pop' + '返回值' + JSON.stringify(popDestinationInfo))
  58.       return true
  59.     })
  60.     .onReady((context: NavDestinationContext) => {
  61.       this.pathStack = context.pathStack
  62.     })
  63.   }
  64. }
  65. // pageTwo
  66. @Component
  67. export struct pageTwoTmp {
  68.   pathStack: NavPathStack = new NavPathStack();
  69.   build() {
  70.     NavDestination() {
  71.       Column() {
  72.         Text("second_page")
  73.       }.width('100%').height('100%')
  74.     }.title("pageTwo")
  75.     .onBackPressed(() => {
  76.       const popDestinationInfo = this.pathStack.pop() // 弹出路由栈栈顶元素
  77.       console.log('pop' + '返回值' + JSON.stringify(popDestinationInfo))
  78.       return true
  79.     })
  80.     .onReady((context: NavDestinationContext) => {
  81.       this.pathStack = context.pathStack
  82.     })
  83.   }
  84. }
  85. // pageThree
  86. @Component
  87. export struct pageThreeTmp {
  88.   pathStack: NavPathStack = new NavPathStack();
  89.   build() {
  90.     NavDestination() {
  91.       Column() {
  92.         Text("third_page")
  93.       }.width('100%').height('100%')
  94.     }.title("pageThree")
  95.     .onBackPressed(() => {
  96.       const popDestinationInfo = this.pathStack.pop() // 弹出路由栈栈顶元素
  97.       console.log('pop' + '返回值' + JSON.stringify(popDestinationInfo))
  98.       return true
  99.     })
  100.     .onReady((context: NavDestinationContext) => {
  101.       this.pathStack = context.pathStack
  102.     })
  103.   }
  104. }
复制代码
另外我们可以直接只调试本页面,看到效果非常不错


以上代码直接就实现了 ,如许想起来 能做东西的方法着实太多了,关键我并没有新建这3个页面,本文没写完 时间不敷了, 明天再来更新 我先发布
ArkUI单选框 (Radio)组件测试

ArkUI单选框 (Radio)组件测试

ArkUI单选框 (Radio)组件测试


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) Powered by Discuz! X3.4