You need to sign in or sign up before continuing.
提交 2de7a6da 编写于 作者: L lixiang

onUrlLoadIntercept is obsolete and onLoadIntercept is used instead

Signed-off-by: Nlixiang <lixiang380@huawei.com>
上级 9a9e637f
......@@ -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.
先完成此消息的编辑!
想要评论请 注册