提交 1ceee25e 编写于 作者: C chensi10

modification of review comments

Signed-off-by: Nchensi10 <chensi52@huawei.com>
上级 b17f4639
...@@ -2226,15 +2226,15 @@ struct WebComponent { ...@@ -2226,15 +2226,15 @@ struct WebComponent {
setNetworkAvailable(enable: boolean): void setNetworkAvailable(enable: boolean): void
设置JavaScript中的window.navigator.isOnline属性。 设置JavaScript中的window.navigator.onLine属性。
**系统能力:** SystemCapability.Web.Webview.Core **系统能力:** SystemCapability.Web.Webview.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ----------------------------------- | | ------ | ------- | ---- | --------------------------------- |
| enable | boolean | 是 | 是否使能window.navigator.isOnline。 | | enable | boolean | 是 | 是否使能window.navigator.onLine。 |
**错误码:** **错误码:**
...@@ -2311,7 +2311,7 @@ struct WebComponent { ...@@ -2311,7 +2311,7 @@ struct WebComponent {
Button('hasImageCb') Button('hasImageCb')
.onClick(() => { .onClick(() => {
this.controller.hasImage((err, data) => { this.controller.hasImage((err, data) => {
console.log("hasImage: " + JSON.stringify(data)); console.log("hasImage: " + data);
}); });
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
...@@ -2359,7 +2359,7 @@ struct WebComponent { ...@@ -2359,7 +2359,7 @@ struct WebComponent {
Button('hasImagePm') Button('hasImagePm')
.onClick(() => { .onClick(() => {
this.controller.hasImage().then((data) => { this.controller.hasImage().then((data) => {
console.info("hasImage:" + JSON.stringify(data)) console.info("hasImage: " + data)
}); });
}) })
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
......
...@@ -688,10 +688,11 @@ blockNetwork(block: boolean) ...@@ -688,10 +688,11 @@ blockNetwork(block: boolean)
```ts ```ts
// xxx.ets // xxx.ets
import web_webview from '@ohos.web.webview'
@Entry @Entry
@Component @Component
struct WebComponent { struct WebComponent {
controller: WebController = new WebController() controller: web_webview.WebviewController = new web_webview.WebviewController()
@State block: boolean = true @State block: boolean = true
build() { build() {
Column() { Column() {
...@@ -2405,13 +2406,13 @@ onDataResubmitted(callback: (event: {handler: DataResubmissionHandler}) => void) ...@@ -2405,13 +2406,13 @@ onDataResubmitted(callback: (event: {handler: DataResubmissionHandler}) => void)
onPageVisible(callback: (event: {url: string}) => void) onPageVisible(callback: (event: {url: string}) => void)
设置页面开始加载时触发的回调函数。 设置旧页面不再呈现,新页面即将可见时触发的回调函数。
**参数:** **参数:**
| 参数名 | 参数类型 | 参数描述 | | 参数名 | 参数类型 | 参数描述 |
| ------ | -------- | ----------------------- | | ------ | -------- | ------------------------------------------------- |
| url | string | 开始加载的页面url地址。 | | url | string | 旧页面不再呈现,新页面即将可见时新页面的url地址。 |
**示例:** **示例:**
...@@ -2445,6 +2446,12 @@ onInterceptKeyEvent(callback: (event: KeyEvent) => boolean) ...@@ -2445,6 +2446,12 @@ onInterceptKeyEvent(callback: (event: KeyEvent) => boolean)
| ------ | ------------------------------------------------------- | -------------------- | | ------ | ------------------------------------------------------- | -------------------- |
| event | [KeyEvent](ts-universal-events-key.md#keyevent对象说明) | 触发的KeyEvent事件。 | | event | [KeyEvent](ts-universal-events-key.md#keyevent对象说明) | 触发的KeyEvent事件。 |
**返回值:**
| 类型 | 说明 |
| ------- | ------------------------------------------------------------ |
| boolean | 回调函数通过返回boolean类型值来决定是否继续将该KeyEvent传入Webview内核。 |
**示例:** **示例:**
```ts ```ts
...@@ -2458,7 +2465,11 @@ onInterceptKeyEvent(callback: (event: KeyEvent) => boolean) ...@@ -2458,7 +2465,11 @@ onInterceptKeyEvent(callback: (event: KeyEvent) => boolean)
Column() { Column() {
Web({ src:'www.example.com', controller: this.controller }) Web({ src:'www.example.com', controller: this.controller })
.onInterceptKeyEvent((event)=>{ .onInterceptKeyEvent((event)=>{
console.log('onInterceptKeyEvent:' + JSON.stringify(event)) if (event.keyCode == 2017 || event.keyCode == 2018) {
console.info(`onInterceptKeyEvent get event.keyCode ${event.keyCode}`)
return true;
}
return false;
}) })
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册