未验证 提交 75299bed 编写于 作者: O openharmony_ci 提交者: Gitee

!16674 onUrlLoadIntercept is obsolete and onLoadIntercept is used instead

Merge pull request !16674 from 李想/master
......@@ -1232,7 +1232,7 @@ struct WebComponent {
}
```
### allowWindowOpenMethod<sup>9+</sup>
### allowWindowOpenMethod<sup>10+</sup>
allowWindowOpenMethod(flag: boolean)
......@@ -2080,11 +2080,12 @@ onScaleChange(callback: (event: {oldScale: number, newScale: number}) => void)
}
```
### onUrlLoadIntercept
### onUrlLoadIntercept<sup>(deprecated)</sup>
onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean)
当Web组件加载url之前触发该回调,用于判断是否阻止此次访问。默认允许加载。
从API version 10开始不在维护,建议使用[onLoadIntercept<sup>10+</sup>](#onloadintercept10)代替。
**参数:**
......@@ -3100,7 +3101,7 @@ onAudioStateChanged(callback: (event: { playing: boolean }) => void)
### onLoadIntercept<sup>10+</sup>
onLoadIntercept(callback: (event?: { request: WebResourceRequest }) => boolean)
onLoadIntercept(callback: (event?: { data: WebResourceRequest }) => boolean)
当Web组件加载url之前触发该回调,用于判断是否阻止此次访问。默认允许加载。
......@@ -3130,11 +3131,11 @@ onLoadIntercept(callback: (event?: { request: WebResourceRequest }) => boolean)
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onUrlLoadIntercept((event) => {
console.log('url:' + event.request.getRequestUrl())
console.log('isMainFrame:' + event.request.isMainFrame())
console.log('isRedirect:' + event.request.isRedirect())
console.log('isRequestGesture:' + event.request.isRequestGesture())
.onLoadIntercept((event) => {
console.log('url:' + event.data.getRequestUrl())
console.log('isMainFrame:' + event.data.isMainFrame())
console.log('isRedirect:' + event.data.isRedirect())
console.log('isRequestGesture:' + event.data.isRequestGesture())
return true
})
}
......@@ -3340,6 +3341,18 @@ isRequestGesture(): boolean
| ------- | -------------------- |
| boolean | 返回资源请求是否与手势(如点击)相关联。 |
### getRequestMethod<sup>9+</sup>
getRequestMethod(): string
获取请求方法。
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| string | 返回请求方法。 |
## Header
Web组件返回的请求/响应头对象。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册