39 Star 666 Fork 206

桃花镇童长老/harmony-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

harmony-web (API12)

🏆简介与推荐

harmony-web 是一款基于鸿蒙 WebView 打造的功能强大且极易上手的库,它不仅轻巧灵便、灵活度极高,还提供了一系列针对鸿蒙 WebView 的问题解决方案,助力开发者轻松应对各类开发挑战。

harmony-utils 一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。

harmony-dialog 一款极为简单易用的零侵入弹窗,仅需一行代码即可轻松实现,无论在何处都能够轻松弹出。

🌞下载安装

ohpm i @pura/harmony-web

OpenHarmony ohpm 环境配置等更多内容,请参考如何安装 OpenHarmony ohpm 包

📚 ArkWeb 组件,参数说明

名称 类型 描述 是否必选
controller webview.WebviewController 控制器 Y
src ResourceStr 网页资源地址 Y
options ArkWebOptions ArkWeb属性参数 N
webClient ArkWebClient ArkWeb生命周期事件 N
arkJsObject ArkJsObject 或 ArkJsObject[] 需要注册的接口对象 N

📚 ArkWebHelper,方法说明

方法名 介绍
init 初始化
prepareForPageLoad 预连接url,在加载url之前调用此API

📚示例代码

@Entry
@ComponentV2
struct Index {
  private controller: webview.WebviewController = new webview.WebviewController();
  @Local webUrl: string = "";
  @Local options: ArkWebOptions = new ArkWebOptions();
  @Local webClient: MyWebClient = new MyWebClient();
  @Local jsObject: MyJsObject = new MyJsObject();

  onBackPress(): boolean {
    if (this.controller?.accessBackward()) {
      this.controller?.backward();
      return true;
    }
    return false;
  }

  aboutToAppear(): void {
    let params: Params = router.getParams() as Params;
    this.webUrl = params.webUrl;
  }

  build() {
    Column() {
      ArkWeb({
        controller: this.controller,
        src: this.webUrl,
        options: this.options,
        webClient: this.webClient,
        arkJsObject: this.jsObject
      })
    }
    .height('100%')
    .width('100%')
  }

}

🍎沟通与交流🙏

使用过程中发现任何问题都可以提 Issue 给我们;
当然,我们也非常欢迎你给我们发 PR

https://gitee.com/tongyuyan/harmony-utils
https://github.com/787107497

鸿蒙技术交流QQ群:1029219059

🌏开源协议

本项目基于 Apache License 2.0 ,在拷贝和借鉴代码时,请大家务必注明出处。

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tongyuyan/harmony-utils.git
git@gitee.com:tongyuyan/harmony-utils.git
tongyuyan
harmony-utils
harmony-utils
master

搜索帮助