【每日学点鸿蒙知识】List+Swipe滑动冲突、下拉刷新、编译错误定位、监听生命周期、上架应用市场要求

1、HarmonyOS List+Swipe+web滑动冲突?

在List中嵌套一个横向滑动的swipe,swipe嵌套一个web,此时设置手势优先的时,web无法和list进行联动交互

题原因可能是List组件嵌套Web组件产生了滑动冲突,这里可以使用触摸测试控制来规避此种情况:.hitTestBehavior(HitTestMode.Block)

参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-gesture-events-multi-level-gesture-V5

2、HarmonyOS Webview如何实现下拉刷新效果?

可以使用pulltorefresh实现下拉刷新。参考链接如下:https://ohpm.openharmony.cn/#/cn/detail/@ohos%2Fpulltorefresh

3、通过Command line进行编译,如果发生错误,如何获取到错误信息,或者能获取到编译成功状态。
  1. 用hvigor进行编译的时候,可用加上各种命令,显示相关日志信息;
  2. 执行命令编译时只会有返回码的:
    • 构建成功:code 0
    • 构建失败:code 1
    • 基于不同平台采用对应方式获取该返回码就行。
4、HarmonyOS 普通对象怎么监听组件生命周期?

可以参考这个:https://gitee.com/openharmony/docs/blob/7ad8e708cebd3e4a43979e97de160da9c0533316/zh-cn/application-dev/reference/apis/js-apis-arkui-observer.md

复制代码
//entryability.ets
import window from '@ohos.window';
import { BusinessError } from '@ohos.base';


interface Data {
  window: window.Window
}

export default class EntryAbility extends UIAbility {
  private window: window.Window | undefined = undefined
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {

    const that : EntryAbility = this
    this.context.eventHub.on("getWindow", (data: Data) => {
      if(that.window != undefined)
      {
        data.window = that.window
      }
      else {
        hilog.info(0x0000, 'testTag', '%{public}s', 'that.subWindowStage == undefined');
      }
    })
  }

  onDestroy(): void {
  }

  onWindowStageCreate(windowStage: window.WindowStage): void {
    // Main window is created, set main page for this ability
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');


    windowStage.loadContent('pages/Index2', (err, data) => {
      if (err.code) {
        hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
        return;
      }
      hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
      // 获取应用主窗口。
      let windowClass: window.Window = window.findWindow("observer0");
      this.window = windowClass
      windowStage.getMainWindow((err: BusinessError, data) => {
        let errCode: number = err.code;
        if (errCode) {
          console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
          return;
        }
      })
    });
  }
  onWindowStageDestroy(): void {
  }
}
//index2.ets
import common from '@ohos.app.ability.common';
import window from '@ohos.window';
import UIContext, { UIObserver } from '@ohos.ArkUI.UIContext';
import observer from '@ohos.ArkUI.observer';
import router from '@ohos.router';

interface Data11 {
  window: window.Window | null
}

@Entry
@Component
struct Index2 {
  private abilityContext: common.UIAbilityContext | null = null;
  private uiContext: UIContext.UIContext | null = null
  private context = getContext(this) as common.UIAbilityContext;

  testFunc(info: observer.RouterPageInfo) {
    console.log("[testFunc][UI-in-Pages] called by: Index2: " + `${info.index}` + ", name: " + `${info.name}` + ", path: " + `${info.path}` + ", state: " + `${info.state}`+ ",context: " + `${info.context}` );
  }
  aboutToAppear() {
    console.log("[Test] aboutToAppear before createWindow");
    this.abilityContext = getContext(this) as common.UIAbilityContext;
    let data : Data11 = {
      window: null
    };
    this.abilityContext.eventHub.emit("getWindow", data);
    if (data.window) {
      this.uiContext = data.window.getUIContext()
    } else {
      this.uiContext = null
    }
    router.getState()
  }
  build() {
    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
      Text('这是Index')
        .fontSize(20)
        .fontWeight(FontWeight.Bold)

      Button('ObserverOn')
        .margin({top:5})
        .onClick(() => {
          let observer: UIObserver | null = this.uiContext ? this.uiContext.getUIObserver() : null
          if (observer) {
            // 注册router页面监听,范围为当前UIContext
            console.log("[Test] set observer to ON");
            observer.on('routerPageUpdate', this.testFunc)
          }
        })
      Button('ObserverOff')
        .margin({top:5})
        .onClick(() => {
          let observer: UIObserver | null = this.uiContext ? this.uiContext.getUIObserver() : null
          if (observer) {
            // 注册router页面监听,范围为当前UIContext
            console.log("[Test] set observer to OFF");
            observer.off('routerPageUpdate', this.testFunc)
          }
        })

      Button('pushUrl PageOne')
        .margin({ top: 5})
        .onClick(() => {
          router.pushUrl({
            url: 'pages/PageOne2',
          })
        })

    }
    .width('100%')
    .height('100%')
    .backgroundColor('#FFBFE5C5')
  }
}
//PageOne2.ets

@Entry
@Component
struct PageOne2 {
  @State message: string = '22222222222';

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .width('100%')
    }
    .height('100%')
  }
}
5、HarmonyOS 设备指纹应用市场的上架SDK需要满足的条件?

需要在应用市场的上架SDK

1、IDE版本需要canary4sp1及以上版本

2、签名证书的帐号和上架SDK的帐号使用企业账号AGC申请发布证书,IDE增加签名指导:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-publish-app-V5

相关推荐
繁依Fanyi1 小时前
我的 PDF 工具箱:CodeBuddy 打造 PDFMagician 的全过程记录
java·pdf·uni-app·生活·harmonyos·codebuddy首席试玩官
Huang兄2 小时前
#跟着若城学鸿蒙# web篇-获取定位
harmonyos
zkmall4 小时前
Java + 鸿蒙双引擎:ZKmall开源商城如何定义下一代B2C商城技术标准?
java·开源·harmonyos
lqj_本人4 小时前
鸿蒙OS&UniApp实现视频播放与流畅加载:打造完美的移动端视频体验#三方框架 #Uniapp
uni-app·音视频·harmonyos
交叉编译之王 hahaha5 小时前
RK3568平台OpenHarmony系统移植可行性评估
华为·harmonyos
_F_y7 小时前
list简单模拟实现
c++·list
lqj_本人7 小时前
鸿蒙OS&UniApp 实现一个精致的日历组件#三方框架 #Uniapp
uni-app·harmonyos
qq_386322698 小时前
华为网路设备学习-22(路由器OSPF-LSA及特殊详解)
学习·华为·智能路由器
Jackilina_Stone8 小时前
【网工】华为配置基础篇①
华为
bestadc12 小时前
鸿蒙 ArkTS 常用的数组和字符串 操作方法
harmonyos