diff --git a/vmall/react-native-webview.md b/vmall/react-native-webview.md index 244d9cd83086d80696637c375b3324d5e9f4e558..220b653dd0c2a85cf7fd025c993e751f4800db5a 100644 --- a/vmall/react-native-webview.md +++ b/vmall/react-native-webview.md @@ -1,3 +1,4 @@ +> 模板版本:v0.1.1

react-native-webview

@@ -10,20 +11,20 @@

+>[!tip] [Github 地址](https://github.com/react-native-oh-library/react-native-webview) + ## 安装与使用 进入到工程目录并输入以下命令: -**正在 npm 发布中,当前请先从仓库[Release](https://github.com/react-native-oh-library/react-native-webview/releases)中获取库 tgz,通过使用本地依赖来安装本库。** - ```bash -yarn add xxx +yarn add @react-native-oh-tpl/react-native-webview ``` 或者 ```bash -npm install xxx +npm install @react-native-oh-tpl/react-native-webview ``` 下面的代码展示了这个库的基本使用场景: @@ -53,7 +54,7 @@ import { WebView } from "react-native-webview"; ```json "dependencies": { "rnoh": "file:../rnoh", - "rnoh-webview": "file:../../node_modules/react-native-webview/harmony/rn_webview.har" + "rnoh-webview": "file:../../node_modules/@react-native-oh-tpl/react-native-webview/harmony/rn_webview.har" } ``` @@ -72,7 +73,7 @@ ohpm install ```json "dependencies": { "rnoh": "file:../rnoh", - "rnoh-webview": "file:../../node_modules/react-native-webview/harmony/rn_webview" + "rnoh-webview": "file:../../node_modules/@react-native-oh-tpl/react-native-webview/harmony/rn_webview" } ``` @@ -136,31 +137,21 @@ std::vector> PackageProvider::getPackages(Package::Cont 打开 `entry/src/main/ets/pages/index.ets`,添加: ```diff -import { - RNApp, - ComponentBuilderContext, - RNAbility, - AnyJSBundleProvider, - MetroJSBundleProvider, - ResourceJSBundleProvider, -} from 'rnoh' -import { SampleView, SAMPLE_VIEW_TYPE, PropsDisplayer } from "rnoh-sample-package" -import { createRNPackages } from '../RNPackagesFactory' + import { WebView, WEB_VIEW } from "rnoh-webview" @Builder function CustomComponentBuilder(ctx: ComponentBuilderContext) { - if (ctx.descriptor.type === SAMPLE_VIEW_TYPE) { + if (ctx.componentName === SAMPLE_VIEW_TYPE) { SampleView({ ctx: ctx.rnohContext, - tag: ctx.descriptor.tag, + tag: ctx.tag, buildCustomComponent: CustomComponentBuilder }) } -+ else if (ctx.descriptor.type === WEB_VIEW) { ++ else if (ctx.componentName === WEB_VIEW) { + WebView({ + ctx: ctx.rnohContext, -+ tag: ctx.descriptor.tag, ++ tag: ctx.tag, + buildCustomComponent: CustomComponentBuilder + }) + } @@ -232,6 +223,7 @@ ohpm install | ` onShouldStartLoadWithRequest?: (event) => void` | Function that allows custom handling of any web view requests. | function | No | iOS,android,macOS | yes | ## 遗留问题 +- [ ] webview部分属性未实现鸿蒙化[issue#17](https://github.com/react-native-oh-library/react-native-webview/issues/17) ## 其他