Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
74ae8dfc
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
74ae8dfc
编写于
7月 22, 2022
作者:
L
laosan_ted
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code
Signed-off-by:
N
laosan_ted
<
wangruichang@huawei.com
>
上级
16d8142f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
673 addition
and
422 deletion
+673
-422
zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md
...ication-dev/reference/arkui-ts/ts-basic-components-web.md
+673
-422
未找到文件。
zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md
浏览文件 @
74ae8dfc
...
@@ -65,7 +65,7 @@ domStorageAccess(domStorageAccess: boolean)
...
@@ -65,7 +65,7 @@ domStorageAccess(domStorageAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
domStorageAccess
(
true
)
.
domStorageAccess
(
true
)
}
}
}
}
...
@@ -92,7 +92,7 @@ fileAccess(fileAccess: boolean)
...
@@ -92,7 +92,7 @@ fileAccess(fileAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
fileAccess
(
true
)
.
fileAccess
(
true
)
}
}
}
}
...
@@ -119,7 +119,7 @@ fileFromUrlAccess(fileFromUrlAccess: boolean)
...
@@ -119,7 +119,7 @@ fileFromUrlAccess(fileFromUrlAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
fileFromUrlAccess
(
true
)
.
fileFromUrlAccess
(
true
)
}
}
}
}
...
@@ -146,7 +146,7 @@ imageAccess(imageAccess: boolean)
...
@@ -146,7 +146,7 @@ imageAccess(imageAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
imageAccess
(
true
)
.
imageAccess
(
true
)
}
}
}
}
...
@@ -187,9 +187,10 @@ javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Arr
...
@@ -187,9 +187,10 @@ javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Arr
}
}
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
javaScriptAccess
(
true
)
.
javaScriptProxy
({
.
javaScriptProxy
({
obj
:
this
.
testObj
,
obj
ect
:
this
.
testObj
,
name
:
"
objName
"
,
name
:
"
objName
"
,
methodList
:
[
"
test
"
,
"
toString
"
],
methodList
:
[
"
test
"
,
"
toString
"
],
controller
:
this
.
controller
,
controller
:
this
.
controller
,
...
@@ -219,7 +220,7 @@ javaScriptAccess(javaScriptAccess: boolean)
...
@@ -219,7 +220,7 @@ javaScriptAccess(javaScriptAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
javaScriptAccess
(
true
)
.
javaScriptAccess
(
true
)
}
}
}
}
...
@@ -242,13 +243,13 @@ mixedMode(mixedMode: MixedMode)
...
@@ -242,13 +243,13 @@ mixedMode(mixedMode: MixedMode)
// xxx.ets
// xxx.ets
@
Entry
@
Entry
@
Component
@
Component
@
State
mode
:
MixedMode
=
MixedMode
.
All
;
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
mode
:
MixedMode
=
MixedMode
.
All
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
mixedMode
(
mode
)
.
mixedMode
(
this
.
mode
)
}
}
}
}
}
}
...
@@ -265,7 +266,6 @@ onlineImageAccess(onlineImageAccess: boolean)
...
@@ -265,7 +266,6 @@ onlineImageAccess(onlineImageAccess: boolean)
| ------ | -------- | ---- | ------ | ------------------------- |
| ------ | -------- | ---- | ------ | ------------------------- |
| onlineImageAccess | boolean | 是 | - | 设置是否允许从网络加载图片资源。 |
| onlineImageAccess | boolean | 是 | - | 设置是否允许从网络加载图片资源。 |
## onlineImageAccess
**示例:**
**示例:**
```
ts
```
ts
// xxx.ets
// xxx.ets
...
@@ -302,7 +302,7 @@ zoomAccess(zoomAccess: boolean)
...
@@ -302,7 +302,7 @@ zoomAccess(zoomAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
zoomAccess
(
true
)
.
zoomAccess
(
true
)
}
}
}
}
...
@@ -329,7 +329,7 @@ overviewModeAccess(overviewModeAccess: boolean)
...
@@ -329,7 +329,7 @@ overviewModeAccess(overviewModeAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
overviewModeAccess
(
true
)
.
overviewModeAccess
(
true
)
}
}
}
}
...
@@ -355,7 +355,7 @@ databaseAccess(databaseAccess: boolean)
...
@@ -355,7 +355,7 @@ databaseAccess(databaseAccess: boolean)
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
.
databaseAccess
(
true
)
}
}
}
}
...
@@ -378,13 +378,13 @@ cacheMode(cacheMode: CacheMode)
...
@@ -378,13 +378,13 @@ cacheMode(cacheMode: CacheMode)
// xxx.ets
// xxx.ets
@
Entry
@
Entry
@
Component
@
Component
@
State
mode
:
CacheMode
=
CacheMode
.
None
;
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
mode
:
CacheMode
=
CacheMode
.
None
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
cacheMode
(
mode
)
.
cacheMode
(
this
.
mode
)
}
}
}
}
}
}
...
@@ -406,13 +406,13 @@ textZoomAtio(textZoomAtio: number)
...
@@ -406,13 +406,13 @@ textZoomAtio(textZoomAtio: number)
// xxx.ets
// xxx.ets
@
Entry
@
Entry
@
Component
@
Component
@
State
atio
:
Number
=
100
;
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
atio
:
number
=
150
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
textZoomAtio
(
atio
)
.
textZoomAtio
(
this
.
atio
)
}
}
}
}
}
}
...
@@ -434,13 +434,13 @@ userAgent(userAgent: string)
...
@@ -434,13 +434,13 @@ userAgent(userAgent: string)
// xxx.ets
// xxx.ets
@
Entry
@
Entry
@
Component
@
Component
@
State
userAgent
:
String
=
'
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
'
;
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
userAgent
:
string
=
'
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
'
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
userAgent
(
userAgent
)
.
userAgent
(
this
.
userAgent
)
}
}
}
}
}
}
...
@@ -481,23 +481,23 @@ onAlert(callback: (event?: { url: string; message: string; result: JsResult }) =
...
@@ -481,23 +481,23 @@ onAlert(callback: (event?: { url: string; message: string; result: JsResult }) =
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onAlert
((
event
)
=>
{
.
onAlert
((
event
)
=>
{
AlertDialog
.
show
({
AlertDialog
.
show
({
title
:
'
title
'
,
title
:
'
title
'
,
message
:
'
text
'
,
message
:
'
text
'
,
confirm
:
{
confirm
:
{
value
:
'
onAlert
'
,
value
:
'
onAlert
'
,
action
:
()
=>
{
action
:
()
=>
{
result
.
handleConfirm
()
event
.
result
.
handleConfirm
()
}
}
},
},
cancel
:
()
=>
{
cancel
:
()
=>
{
result
.
handleCancel
()
event
.
result
.
handleCancel
()
}
}
})
return
true
;
})
})
return
true
;
})
}
}
}
}
}
}
...
@@ -527,16 +527,18 @@ onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResu
...
@@ -527,16 +527,18 @@ onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResu
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onBeforeUnload
((
event
)
=>
{
.
onBeforeUnload
((
event
)
=>
{
console
.
log
(
"
event.url:
"
+
url
);
console
.
log
(
"
event.url:
"
+
event
.
url
);
console
.
log
(
"
event.message:
"
+
message
);
console
.
log
(
"
event.message:
"
+
event
.
message
);
console
.
log
(
"
event.result:
"
+
result
);
console
.
log
(
"
event.result:
"
+
event
.
result
);
return
false
;
return
false
;
})
})
}
}
}
}
}
```
```
...
@@ -565,29 +567,31 @@ onConfirm(callback: (event?: { url: string; message: string; result: JsResult })
...
@@ -565,29 +567,31 @@ onConfirm(callback: (event?: { url: string; message: string; result: JsResult })
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onConfirm
((
event
)
=>
{
.
onConfirm
((
event
)
=>
{
console
.
log
(
"
event.url:
"
+
url
);
console
.
log
(
"
event.url:
"
+
event
.
url
);
console
.
log
(
"
event.message:
"
+
message
);
console
.
log
(
"
event.message:
"
+
event
.
message
);
console
.
log
(
"
event.result:
"
+
result
);
console
.
log
(
"
event.result:
"
+
event
.
result
);
AlertDialog
.
show
({
AlertDialog
.
show
({
title
:
'
title
'
,
title
:
'
title
'
,
message
:
'
text
'
,
message
:
'
text
'
,
confirm
:
{
confirm
:
{
value
:
'
onConfirm
'
,
value
:
'
onConfirm
'
,
action
:
()
=>
{
action
:
()
=>
{
result
.
handleConfirm
()
event
.
result
.
handleConfirm
()
}
}
},
},
cancel
:
()
=>
{
cancel
:
()
=>
{
result
.
handleCancel
()
event
.
result
.
handleCancel
()
}
}
})
return
true
;
})
})
return
true
;
}
})
}
}
}
}
```
```
...
@@ -617,7 +621,7 @@ onPrompt(callback: (event?: { url: string; message: string; value: string; resul
...
@@ -617,7 +621,7 @@ onPrompt(callback: (event?: { url: string; message: string; value: string; resul
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
onPrompt
((
event
)
=>
{
.
onPrompt
((
event
)
=>
{
console
.
log
(
"
url:
"
+
event
.
url
);
console
.
log
(
"
url:
"
+
event
.
url
);
console
.
log
(
"
message:
"
+
event
.
message
);
console
.
log
(
"
message:
"
+
event
.
message
);
...
@@ -651,17 +655,19 @@ onConsole(callback: (event?: { message: ConsoleMessage }) => boolean)
...
@@ -651,17 +655,19 @@ onConsole(callback: (event?: { message: ConsoleMessage }) => boolean)
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onConsole
((
event
)
=>
{
.
onConsole
((
event
)
=>
{
console
.
log
(
'
getMessage:
'
+
message
.
getMessage
());
console
.
log
(
'
getMessage:
'
+
event
.
message
.
getMessage
());
console
.
log
(
'
getSourceId:
'
+
message
.
getSourceId
());
console
.
log
(
'
getSourceId:
'
+
event
.
message
.
getSourceId
());
console
.
log
(
'
getLineNumber:
'
+
message
.
getLineNumber
());
console
.
log
(
'
getLineNumber:
'
+
event
.
message
.
getLineNumber
());
console
.
log
(
'
getMessageLevel:
'
+
message
.
getMessageLevel
());
console
.
log
(
'
getMessageLevel:
'
+
event
.
message
.
getMessageLevel
());
return
false
;
return
false
;
})
})
}
}
}
}
}
```
```
...
@@ -684,17 +690,19 @@ onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisp
...
@@ -684,17 +690,19 @@ onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisp
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onDownloadStart
((
event
)
=>
{
.
onDownloadStart
((
event
)
=>
{
console
.
log
(
'
url:
'
+
url
);
console
.
log
(
'
url:
'
+
event
.
url
);
console
.
log
(
'
userAgent:
'
+
userAgent
);
console
.
log
(
'
userAgent:
'
+
event
.
userAgent
);
console
.
log
(
'
contentDisposition:
'
+
contentDisposition
);
console
.
log
(
'
contentDisposition:
'
+
event
.
contentDisposition
);
console
.
log
(
'
contentLength:
'
+
contentLength
);
console
.
log
(
'
contentLength:
'
+
event
.
contentLength
);
console
.
log
(
'
mimetype:
'
+
mimetype
);
console
.
log
(
'
mimetype:
'
+
event
.
mimetype
);
})
})
}
}
}
}
}
```
```
...
@@ -717,24 +725,26 @@ onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResou
...
@@ -717,24 +725,26 @@ onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResou
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onErrorReceive
((
event
)
=>
{
.
onErrorReceive
((
event
)
=>
{
console
.
log
(
'
getErrorInfo:
'
+
error
.
getErrorInfo
());
console
.
log
(
'
getErrorInfo:
'
+
event
.
error
.
getErrorInfo
());
console
.
log
(
'
getErrorCode:
'
+
error
.
getErrorCode
());
console
.
log
(
'
getErrorCode:
'
+
event
.
error
.
getErrorCode
());
console
.
log
(
'
url:
'
+
request
.
getRequestUrl
());
console
.
log
(
'
url:
'
+
event
.
request
.
getRequestUrl
());
console
.
log
(
'
isMainFrame:
'
+
request
.
isMainFrame
());
console
.
log
(
'
isMainFrame:
'
+
event
.
request
.
isMainFrame
());
console
.
log
(
'
isRedirect:
'
+
request
.
isRedirect
());
console
.
log
(
'
isRedirect:
'
+
event
.
request
.
isRedirect
());
console
.
log
(
'
isRequestGesture:
'
+
request
.
isRequestGesture
());
console
.
log
(
'
isRequestGesture:
'
+
event
.
request
.
isRequestGesture
());
console
.
log
(
'
getRequestHeader_headerKey:
'
+
request
.
getRequestHeader
().
toString
());
console
.
log
(
'
getRequestHeader_headerKey:
'
+
event
.
request
.
getRequestHeader
().
toString
());
let
result
=
request
.
getRequestHeader
();
let
result
=
event
.
request
.
getRequestHeader
();
console
.
log
(
'
The request header result size is
'
+
result
.
length
);
console
.
log
(
'
The request header result size is
'
+
result
.
length
);
for
(
let
i
of
result
)
{
for
(
let
i
of
result
)
{
console
.
log
(
'
The request header key is :
'
+
i
.
headerKey
+
'
, value is :
'
+
i
.
headerValue
);
console
.
log
(
'
The request header key is :
'
+
i
.
headerKey
+
'
, value is :
'
+
i
.
headerValue
);
}
}
})
})
}
}
}
}
}
```
```
...
@@ -757,31 +767,33 @@ onHttpErrorReceive(callback: (event?: { request: WebResourceRequest, response: W
...
@@ -757,31 +767,33 @@ onHttpErrorReceive(callback: (event?: { request: WebResourceRequest, response: W
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onHttpErrorReceive
((
event
)
=>
{
.
onHttpErrorReceive
((
event
)
=>
{
console
.
log
(
'
url:
'
+
request
.
getRequestUrl
());
console
.
log
(
'
url:
'
+
event
.
request
.
getRequestUrl
());
console
.
log
(
'
isMainFrame:
'
+
request
.
isMainFrame
());
console
.
log
(
'
isMainFrame:
'
+
event
.
request
.
isMainFrame
());
console
.
log
(
'
isRedirect:
'
+
request
.
isRedirect
());
console
.
log
(
'
isRedirect:
'
+
event
.
request
.
isRedirect
());
console
.
log
(
'
isRequestGesture:
'
+
request
.
isRequestGesture
());
console
.
log
(
'
isRequestGesture:
'
+
event
.
request
.
isRequestGesture
());
console
.
log
(
'
getResponseData:
'
+
response
.
getResponseData
());
console
.
log
(
'
getResponseData:
'
+
event
.
response
.
getResponseData
());
console
.
log
(
'
getResponseEncoding:
'
+
response
.
getResponseEncoding
());
console
.
log
(
'
getResponseEncoding:
'
+
event
.
response
.
getResponseEncoding
());
console
.
log
(
'
getResponseMimeType:
'
+
response
.
getResponseMimeType
());
console
.
log
(
'
getResponseMimeType:
'
+
event
.
response
.
getResponseMimeType
());
console
.
log
(
'
getResponseCode:
'
+
response
.
getResponseCode
());
console
.
log
(
'
getResponseCode:
'
+
event
.
response
.
getResponseCode
());
console
.
log
(
'
getReasonMessage:
'
+
response
.
getReasonMessage
());
console
.
log
(
'
getReasonMessage:
'
+
event
.
response
.
getReasonMessage
());
let
result
=
request
.
getRequestHeader
();
let
result
=
event
.
request
.
getRequestHeader
();
console
.
log
(
'
The request header result size is
'
+
result
.
length
);
console
.
log
(
'
The request header result size is
'
+
result
.
length
);
for
(
let
i
of
result
)
{
for
(
let
i
of
result
)
{
console
.
log
(
'
The request header key is :
'
+
i
.
headerKey
+
'
, value is :
'
+
i
.
headerValue
);
console
.
log
(
'
The request header key is :
'
+
i
.
headerKey
+
'
, value is :
'
+
i
.
headerValue
);
}
}
let
resph
=
response
.
getResponseHeader
();
let
resph
=
event
.
response
.
getResponseHeader
();
console
.
log
(
'
The response header result size is
'
+
resph
.
length
);
console
.
log
(
'
The response header result size is
'
+
resph
.
length
);
for
(
let
i
of
resph
)
{
for
(
let
i
of
resph
)
{
console
.
log
(
'
The response header key is :
'
+
i
.
headerKey
+
'
, value is :
'
+
i
.
headerValue
);
console
.
log
(
'
The response header key is :
'
+
i
.
headerKey
+
'
, value is :
'
+
i
.
headerValue
);
}
}
})
})
}
}
}
}
}
```
```
...
@@ -804,13 +816,15 @@ onPageBegin(callback: (event?: { url: string }) => void)
...
@@ -804,13 +816,15 @@ onPageBegin(callback: (event?: { url: string }) => void)
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onPageBegin
((
event
)
=>
{
.
onPageBegin
((
event
)
=>
{
console
.
log
(
'
url:
'
+
url
);
console
.
log
(
'
url:
'
+
event
.
url
);
})
})
}
}
}
}
}
```
```
...
@@ -833,13 +847,15 @@ onPageEnd(callback: (event?: { url: string }) => void)
...
@@ -833,13 +847,15 @@ onPageEnd(callback: (event?: { url: string }) => void)
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onPageEnd
((
event
)
=>
{
.
onPageEnd
((
event
)
=>
{
console
.
log
(
'
url:
'
+
url
);
console
.
log
(
'
url:
'
+
event
.
url
);
})
})
}
}
}
}
}
```
```
...
@@ -861,13 +877,15 @@ onProgressChange(callback: (event?: { newProgress: number }) => void)
...
@@ -861,13 +877,15 @@ onProgressChange(callback: (event?: { newProgress: number }) => void)
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onProgressChange
((
event
)
=>
{
.
onProgressChange
((
event
)
=>
{
console
.
log
(
'
newProgress:
'
+
newProgress
)
console
.
log
(
'
newProgress:
'
+
event
.
newProgress
)
})
})
}
}
}
}
}
```
```
...
@@ -889,13 +907,15 @@ onTitleReceive(callback: (event?: { title: string }) => void)
...
@@ -889,13 +907,15 @@ onTitleReceive(callback: (event?: { title: string }) => void)
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onTitleReceive
((
event
)
=>
{
.
onTitleReceive
((
event
)
=>
{
console
.
log
(
'
title:
'
+
title
)
console
.
log
(
'
title:
'
+
event
.
title
)
})
})
}
}
}
}
}
```
```
...
@@ -918,13 +938,15 @@ onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean
...
@@ -918,13 +938,15 @@ onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onRefreshAccessedHistory
((
event
)
=>
{
.
onRefreshAccessedHistory
((
event
)
=>
{
console
.
log
(
'
url:
'
+
url
+
'
isReload:
'
+
isRefreshed
);
console
.
log
(
'
url:
'
+
event
.
url
+
'
isReload:
'
+
event
.
refreshed
);
})
})
}
}
}
}
}
```
```
...
@@ -946,13 +968,15 @@ onRenderExited(callback: (event?: { renderExitReason: RenderExitReason }) => voi
...
@@ -946,13 +968,15 @@ onRenderExited(callback: (event?: { renderExitReason: RenderExitReason }) => voi
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
chrome://crash/
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
chrome://crash/
'
,
controller
:
this
.
controller
})
.
onRenderExited
((
event
)
=>
{
.
onRenderExited
((
event
)
=>
{
console
.
log
(
'
reason:
'
+
renderExitReason
);
console
.
log
(
'
reason:
'
+
event
.
renderExitReason
);
})
})
}
}
}
}
}
```
```
...
@@ -975,30 +999,32 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
...
@@ -975,30 +999,32 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onShowFileSelector
((
event
)
=>
{
.
onShowFileSelector
((
event
)
=>
{
AlertDialog
.
show
({
AlertDialog
.
show
({
title
:
fileSelector
.
getTitle
(),
title
:
event
.
fileSelector
.
getTitle
(),
message
:
'
isCapture:
'
+
fileSelector
.
isCapture
()
+
"
mode:
"
+
fileSelector
.
getMode
()
+
'
acceptType:
'
+
fileSelector
.
getAcceptType
(),
message
:
'
isCapture:
'
+
event
.
fileSelector
.
isCapture
()
+
"
mode:
"
+
event
.
fileSelector
.
getMode
()
+
'
acceptType:
'
+
event
.
fileSelector
.
getAcceptType
(),
confirm
:
{
confirm
:
{
value
:
'
upload
'
,
value
:
'
upload
'
,
action
:
()
=>
{
action
:
()
=>
{
let
fileList
:
Array
<
string
>
=
[
let
fileList
:
Array
<
string
>
=
[
'
/data/storage/el2/base/test
'
,
'
/data/storage/el2/base/test
'
,
]
]
result
.
handleFileList
(
fileList
)
event
.
result
.
handleFileList
(
fileList
)
}
},
cancel
:
()
=>
{
let
fileList
:
Array
<
string
>
=
[]
event
.
result
.
handleFileList
(
fileList
)
}
}
},
})
cancel
:
()
=>
{
return
true
;
let
fileList
:
Array
<
string
>
=
[]
result
.
handleFileList
(
fileList
)
}
})
})
return
true
;
}
})
}
}
}
}
```
```
...
@@ -1025,14 +1051,16 @@ onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => b
...
@@ -1025,14 +1051,16 @@ onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => b
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
.
onUrlLoadIntercept
((
event
)
=>
{
.
onUrlLoadIntercept
((
event
)
=>
{
console
.
log
(
'
onUrlLoadIntercept
'
+
data
.
toString
())
console
.
log
(
'
onUrlLoadIntercept
'
+
event
.
data
.
toString
())
return
true
;
return
true
;
})
})
}
}
}
}
}
```
```
...
@@ -1060,29 +1088,40 @@ onInterceptRequest9+(callback: (event?: { request: WebResourceRequest}) => WebRe
...
@@ -1060,29 +1088,40 @@ onInterceptRequest9+(callback: (event?: { request: WebResourceRequest}) => WebRe
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
responseweb
:
WebResourceResponse
=
new
WebResourceResponse
();
heads
:
Header
[]
=
new
Array
();
@
State
webdata
:
string
=
"
<!DOCTYPE html>
\n
"
+
"
<html>
\n
"
+
"
<head>
\n
"
+
"
<title>intercept test</title>
\n
"
+
"
</head>
\n
"
+
"
<body>
\n
"
+
"
<h1>intercept test</h1>
\n
"
+
"
</body>
\n
"
+
"
</html>
"
build
()
{
build
()
{
Column
()
{
Column
()
{
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
.
onInterceptRequest
((
e
)
=>
{
.
onInterceptRequest
((
event
)
=>
{
console
.
log
(
'
url:
'
+
e
.
request
.
getRequestUrl
());
console
.
log
(
'
url:
'
+
event
.
request
.
getRequestUrl
());
var
head1
:
Header
=
{
var
head1
:
Header
=
{
headerKey
:
"
Connection
"
,
headerKey
:
"
Connection
"
,
headerValue
:
"
keep-alive
"
headerValue
:
"
keep-alive
"
}
}
var
head2
:
Header
=
{
var
head2
:
Header
=
{
headerKey
:
"
Cache-Control
"
,
headerKey
:
"
Cache-Control
"
,
headerValue
:
"
no-cache
"
headerValue
:
"
no-cache
"
}
}
var
length
=
this
.
heads
.
push
(
head1
);
var
length
=
this
.
heads
.
push
(
head1
);
length
=
this
.
heads
.
push
(
head2
);
length
=
this
.
heads
.
push
(
head2
);
this
.
responseweb
.
setResponseHeader
(
this
.
heads
);
this
.
responseweb
.
setResponseHeader
(
this
.
heads
);
this
.
responseweb
.
setResponseData
(
this
.
webdata
);
this
.
responseweb
.
setResponseData
(
this
.
webdata
);
this
.
responseweb
.
setResponseEncoding
(
'
utf-8
'
);
this
.
responseweb
.
setResponseEncoding
(
'
utf-8
'
);
this
.
responseweb
.
setResponseMimeType
(
'
text/html
'
);
this
.
responseweb
.
setResponseMimeType
(
'
text/html
'
);
this
.
responseweb
.
setResponseCode
(
200
);
this
.
responseweb
.
setResponseCode
(
200
);
this
.
responseweb
.
setReasonMessage
(
'
OK
'
);
this
.
responseweb
.
setReasonMessage
(
'
OK
'
);
return
this
.
responseweb
;
return
this
.
responseweb
;
})
})
}
}
}
}
}
}
...
@@ -1581,15 +1620,17 @@ accessBackward(): boolean
...
@@ -1581,15 +1620,17 @@ accessBackward(): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
accessBackward
'
)
Button
(
'
accessBackward
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
accessBackward
();
let
result
=
this
.
controller
.
accessBackward
();
console
.
log
(
'
result:
'
+
result
);
console
.
log
(
'
result:
'
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1611,15 +1652,17 @@ accessForward(): boolean
...
@@ -1611,15 +1652,17 @@ accessForward(): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
accessForward
'
)
Button
(
'
accessForward
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
accessForward
();
let
result
=
this
.
controller
.
accessForward
();
console
.
log
(
'
result:
'
+
result
);
console
.
log
(
'
result:
'
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1647,16 +1690,18 @@ accessStep(step: number): boolean
...
@@ -1647,16 +1690,18 @@ accessStep(step: number): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
steps
:
number
=
2
;
@
State
steps
:
number
=
2
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
accessStep
'
)
Button
(
'
accessStep
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
accessStep
(
this
.
steps
);
let
result
=
this
.
controller
.
accessStep
(
this
.
steps
);
console
.
log
(
'
result:
'
+
result
);
console
.
log
(
'
result:
'
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1673,14 +1718,16 @@ backward(): void
...
@@ -1673,14 +1718,16 @@ backward(): void
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
backward
'
)
Button
(
'
backward
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
backward
();
this
.
controller
.
backward
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1697,14 +1744,16 @@ forward(): void
...
@@ -1697,14 +1744,16 @@ forward(): void
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
forward
'
)
Button
(
'
forward
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
forward
();
this
.
controller
.
forward
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1733,7 +1782,7 @@ backOrForward(step: number): void
...
@@ -1733,7 +1782,7 @@ backOrForward(step: number): void
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
backOrForward
();
this
.
controller
.
backOrForward
();
})
})
Web
({
src
:
'
www.
exampl
e.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.
gite
e.com
'
,
controller
:
this
.
controller
})
}
}
}
}
```
```
...
@@ -1755,15 +1804,17 @@ deleteJavaScriptRegister(name: string)
...
@@ -1755,15 +1804,17 @@ deleteJavaScriptRegister(name: string)
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
name
:
string
=
'
Object
'
;
@
State
name
:
string
=
'
Object
'
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
deleteJavaScriptRegister
'
)
Button
(
'
deleteJavaScriptRegister
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
deleteJavaScriptRegister
(
this
.
name
);
this
.
controller
.
deleteJavaScriptRegister
(
this
.
name
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1785,15 +1836,17 @@ getHitTest(): HitTestType
...
@@ -1785,15 +1836,17 @@ getHitTest(): HitTestType
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getHitTest
'
)
Button
(
'
getHitTest
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
hitType
=
this
.
controller
.
getHitTest
();
let
hitType
=
this
.
controller
.
getHitTest
();
console
.
log
(
"
hitType:
"
+
hitType
);
console
.
log
(
"
hitType:
"
+
hitType
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1814,16 +1867,18 @@ getHitTestValue(): HitTestValue
...
@@ -1814,16 +1867,18 @@ getHitTestValue(): HitTestValue
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getHitTestValue
'
)
Button
(
'
getHitTestValue
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
hitValue
=
this
.
controller
.
getHitTestValue
();
let
hitValue
=
this
.
controller
.
getHitTestValue
();
console
.
log
(
"
hitType:
"
+
hitValue
.
getType
());
console
.
log
(
"
hitType:
"
+
hitValue
.
getType
());
console
.
log
(
"
extra:
"
+
hitValue
.
getExtra
());
console
.
log
(
"
extra:
"
+
hitValue
.
getExtra
());
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1844,15 +1899,17 @@ getWebId(): number
...
@@ -1844,15 +1899,17 @@ getWebId(): number
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getWebId
'
)
Button
(
'
getWebId
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
id
=
this
.
controller
.
getWebId
();
let
id
=
this
.
controller
.
getWebId
();
console
.
log
(
"
id:
"
+
id
);
console
.
log
(
"
id:
"
+
id
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1873,15 +1930,17 @@ getTitle(): string
...
@@ -1873,15 +1930,17 @@ getTitle(): string
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getTitle
'
)
Button
(
'
getTitle
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
title
=
this
.
controller
.
getTitle
();
let
title
=
this
.
controller
.
getTitle
();
console
.
log
(
"
title:
"
+
title
);
console
.
log
(
"
title:
"
+
title
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1902,15 +1961,17 @@ getPageHeight(): number
...
@@ -1902,15 +1961,17 @@ getPageHeight(): number
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getPageHeight
'
)
Button
(
'
getPageHeight
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
pageHeight
=
this
.
controller
.
getPageHeight
();
let
pageHeight
=
this
.
controller
.
getPageHeight
();
console
.
log
(
"
pageHeight:
"
+
pageHeight
);
console
.
log
(
"
pageHeight:
"
+
pageHeight
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1931,15 +1992,17 @@ getDefaultUserAgent(): string
...
@@ -1931,15 +1992,17 @@ getDefaultUserAgent(): string
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getDefaultUserAgent
'
)
Button
(
'
getDefaultUserAgent
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
userAgent
=
this
.
controller
.
getDefaultUserAgent
();
let
userAgent
=
this
.
controller
.
getDefaultUserAgent
();
console
.
log
(
"
userAgent:
"
+
userAgent
);
console
.
log
(
"
userAgent:
"
+
userAgent
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -1969,18 +2032,20 @@ baseUrl为空时,通过”data“协议加载指定的一段字符串。
...
@@ -1969,18 +2032,20 @@ baseUrl为空时,通过”data“协议加载指定的一段字符串。
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
loadData
'
)
Button
(
'
loadData
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
loadData
({
this
.
controller
.
loadData
({
data
:
"
<html><body bgcolor=
\"
white
\"
>Source:<pre>source</pre></body></html>
"
,
data
:
"
<html><body bgcolor=
\"
white
\"
>Source:<pre>source</pre></body></html>
"
,
mimeType
:
"
text/html
"
,
mimeType
:
"
text/html
"
,
encoding
:
"
UTF-8
"
encoding
:
"
UTF-8
"
});
});
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2007,14 +2072,16 @@ loadUrl(options: { url: string | Resource, headers?: Array\<Header\> })
...
@@ -2007,14 +2072,16 @@ loadUrl(options: { url: string | Resource, headers?: Array\<Header\> })
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
loadUrl
'
)
Button
(
'
loadUrl
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
loadUrl
(
'
https://gitee.com/
'
);
this
.
controller
.
loadUrl
({
url
:
'
https://gitee.com/
'
});
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2031,14 +2098,16 @@ onActive(): void
...
@@ -2031,14 +2098,16 @@ onActive(): void
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
onActive
'
)
Button
(
'
onActive
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
onActive
();
this
.
controller
.
onActive
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2055,14 +2124,16 @@ onInactive(): void
...
@@ -2055,14 +2124,16 @@ onInactive(): void
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
onInactive
'
)
Button
(
'
onInactive
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
onInactive
();
this
.
controller
.
onInactive
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2083,15 +2154,17 @@ zoom(factor: number): void
...
@@ -2083,15 +2154,17 @@ zoom(factor: number): void
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
@
State
factor
:
number
=
1
;
@
State
factor
:
number
=
1
;
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
zoom
'
)
Button
(
'
zoom
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
zoom
(
this
.
factor
);
this
.
controller
.
zoom
(
this
.
factor
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2112,15 +2185,17 @@ zoomIn(): boolean
...
@@ -2112,15 +2185,17 @@ zoomIn(): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
zoomIn
'
)
Button
(
'
zoomIn
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
zoomIn
();
let
result
=
this
.
controller
.
zoomIn
();
console
.
log
(
"
result:
"
+
result
);
console
.
log
(
"
result:
"
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2141,15 +2216,17 @@ zoomOut(): boolean
...
@@ -2141,15 +2216,17 @@ zoomOut(): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
zoomOut
'
)
Button
(
'
zoomOut
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
zoomOut
();
let
result
=
this
.
controller
.
zoomOut
();
console
.
log
(
"
result:
"
+
result
);
console
.
log
(
"
result:
"
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2166,14 +2243,16 @@ refresh()
...
@@ -2166,14 +2243,16 @@ refresh()
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
refresh
'
)
Button
(
'
refresh
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
refresh
();
this
.
controller
.
refresh
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2200,7 +2279,6 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
...
@@ -2200,7 +2279,6 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
controller
:
WebController
=
new
WebController
()
controller
:
WebController
=
new
WebController
()
testObj
=
{
testObj
=
{
test
:
(
data
)
=>
{
test
:
(
data
)
=>
{
prompt
.
showToast
({
message
:
"
test:
"
+
data
,
duration
:
2000
})
return
"
ArkUI Web Component
"
;
return
"
ArkUI Web Component
"
;
},
},
toString
:
()
=>
{
toString
:
()
=>
{
...
@@ -2210,14 +2288,6 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
...
@@ -2210,14 +2288,6 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
build
()
{
build
()
{
Column
()
{
Column
()
{
Row
()
{
Row
()
{
Button
(
'
htmlTest
'
).
onClick
(()
=>
{
this
.
controller
.
runJavaScript
({
script
:
"
htmlTest()
"
})
})
Button
(
'
refresh
'
).
onClick
(()
=>
{
this
.
controller
.
refresh
()
})
Button
(
'
Register JavaScript To Window
'
).
onClick
(()
=>
{
Button
(
'
Register JavaScript To Window
'
).
onClick
(()
=>
{
this
.
controller
.
registerJavaScriptProxy
({
this
.
controller
.
registerJavaScriptProxy
({
object
:
this
.
testObj
,
object
:
this
.
testObj
,
...
@@ -2234,6 +2304,7 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
...
@@ -2234,6 +2304,7 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
```
```
```
html
```
html
<!-- index.html -->
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
...
@@ -2242,7 +2313,6 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
...
@@ -2242,7 +2313,6 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
</body>
</body>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
function
htmlTest
()
{
function
htmlTest
()
{
// 调用主应用注入的objName.test方法
str
=
objName
.
test
(
"
test function
"
);
str
=
objName
.
test
(
"
test function
"
);
console
.
log
(
'
objName.test result:
'
+
str
);
console
.
log
(
'
objName.test result:
'
+
str
);
}
}
...
@@ -2291,6 +2361,7 @@ runJavaScript(options: { script: string, callback?: (result: string) => void })
...
@@ -2291,6 +2361,7 @@ runJavaScript(options: { script: string, callback?: (result: string) => void })
```
```
```
html
```
html
<!-- index.html -->
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
...
@@ -2319,14 +2390,16 @@ stop()
...
@@ -2319,14 +2390,16 @@ stop()
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
stop
'
)
Button
(
'
stop
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
stop
();
this
.
controller
.
stop
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2343,14 +2416,16 @@ clearHistory(): void
...
@@ -2343,14 +2416,16 @@ clearHistory(): void
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
clearHistory
'
)
Button
(
'
clearHistory
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
this
.
controller
.
clearHistory
();
this
.
controller
.
clearHistory
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2372,14 +2447,16 @@ getCookieManager(): WebCookie
...
@@ -2372,14 +2447,16 @@ getCookieManager(): WebCookie
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
getCookieManager
'
)
Button
(
'
getCookieManager
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
cookieManager
=
this
.
controller
.
getCookieManager
();
let
cookieManager
=
this
.
controller
.
getCookieManager
();
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2433,15 +2510,17 @@ setCookie(url: string, value: string): boolean
...
@@ -2433,15 +2510,17 @@ setCookie(url: string, value: string): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
setCookie
'
)
Button
(
'
setCookie
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
getCookieManager
().
setCookie
(
"
http://www.example.com
"
,
"
a=b
"
);
let
result
=
this
.
controller
.
getCookieManager
().
setCookie
(
"
http://www.baidu.com
"
,
"
a=b
"
);
console
.
log
(
"
result:
"
+
result
);
console
.
log
(
"
result:
"
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2462,15 +2541,17 @@ saveCookieSync(): boolean
...
@@ -2462,15 +2541,17 @@ saveCookieSync(): boolean
@
Entry
@
Entry
@
Component
@
Component
struct
WebComponent
{
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
controller
:
WebController
=
new
WebController
();
build
()
{
build
()
{
Column
()
{
Column
()
{
Button
(
'
saveCookieSync
'
)
Button
(
'
saveCookieSync
'
)
.
onClick
(()
=>
{
.
onClick
(()
=>
{
let
result
=
this
.
controller
.
getCookieManager
().
saveCookieSync
();
let
result
=
this
.
controller
.
getCookieManager
().
saveCookieSync
();
console
.
log
(
"
result:
"
+
result
);
console
.
log
(
"
result:
"
+
result
);
})
})
Web
({
src
:
'
www.example.com
'
,
controller
:
this
.
controller
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
}
}
```
```
...
@@ -2493,8 +2574,22 @@ static existHttpAuthCredentials(): boolean
...
@@ -2493,8 +2574,22 @@ static existHttpAuthCredentials(): boolean
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
let
result
=
web
.
WebDataBase
.
existHttpAuthCredentials
();
@
Entry
console
.
log
(
'
result:
'
+
result
);
@
Component
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
build
()
{
Column
()
{
Button
(
'
existHttpAuthCredentials
'
)
.
onClick
(()
=>
{
let
result
=
web
.
WebDataBase
.
existHttpAuthCredentials
();
console
.
log
(
'
result:
'
+
result
);
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
```
```
### deleteHttpAuthCredentials<sup>9+</sup>
### deleteHttpAuthCredentials<sup>9+</sup>
...
@@ -2507,7 +2602,21 @@ static deleteHttpAuthCredentials(): void
...
@@ -2507,7 +2602,21 @@ static deleteHttpAuthCredentials(): void
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
web
.
WebDataBase
.
deleteHttpAuthCredentials
();
@
Entry
@
Component
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
build
()
{
Column
()
{
Button
(
'
deleteHttpAuthCredentials
'
)
.
onClick
(()
=>
{
web
.
WebDataBase
.
deleteHttpAuthCredentials
();
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
```
```
### getHttpAuthCredentials<sup>9+</sup>
### getHttpAuthCredentials<sup>9+</sup>
...
@@ -2531,14 +2640,27 @@ static getHttpAuthCredentials(host: string, realm: string): Array\<string\>
...
@@ -2531,14 +2640,27 @@ static getHttpAuthCredentials(host: string, realm: string): Array\<string\>
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
host
:
string
=
"
www.spincast.org
"
;
@
Entry
realm
:
string
=
"
protected example
"
;
@
Component
username_password
:
string
[];
struct
WebComponent
{
this
.
username_password
=
web
.
WebDataBase
.
getHttpAuthCredentials
(
this
.
host
,
this
.
realm
);
controller
:
WebController
=
new
WebController
();
console
.
log
(
'
num:
'
+
this
.
username_password
.
length
);
host
:
string
=
"
www.spincast.org
"
;
ForEach
(
this
.
username_password
,
(
item
)
=>
{
realm
:
string
=
"
protected example
"
;
console
.
log
(
'
username_password:
'
+
item
);
username_password
:
string
[];
},
item
=>
item
)
build
()
{
Column
()
{
Button
(
'
getHttpAuthCredentials
'
)
.
onClick
(()
=>
{
this
.
username_password
=
web
.
WebDataBase
.
getHttpAuthCredentials
(
this
.
host
,
this
.
realm
);
console
.
log
(
'
num:
'
+
this
.
username_password
.
length
);
ForEach
(
this
.
username_password
,
(
item
)
=>
{
console
.
log
(
'
username_password:
'
+
item
);
},
item
=>
item
)
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
```
```
### saveHttpAuthCredentials<sup>9+</sup>
### saveHttpAuthCredentials<sup>9+</sup>
...
@@ -2559,9 +2681,22 @@ static saveHttpAuthCredentials(host: string, realm: string, username: string, pa
...
@@ -2559,9 +2681,22 @@ static saveHttpAuthCredentials(host: string, realm: string, username: string, pa
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
host
:
string
=
"
www.spincast.org
"
;
@
Entry
realm
:
string
=
"
protected example
"
;
@
Component
web
.
WebDataBase
.
saveHttpAuthCredentials
(
this
.
host
,
this
.
realm
,
"
Stromgol
"
,
"
Laroche
"
);
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
host
:
string
=
"
www.spincast.org
"
;
realm
:
string
=
"
protected example
"
;
build
()
{
Column
()
{
Button
(
'
saveHttpAuthCredentials
'
)
.
onClick
(()
=>
{
web
.
WebDataBase
.
saveHttpAuthCredentials
(
this
.
host
,
this
.
realm
,
"
Stromgol
"
,
"
Laroche
"
);
})
Web
({
src
:
'
www.gitee.com
'
,
controller
:
this
.
controller
})
}
}
}
```
```
## WebStorage<sup>9+</sup>
## WebStorage<sup>9+</sup>
...
@@ -2575,7 +2710,21 @@ static deleteAllData(): void
...
@@ -2575,7 +2710,21 @@ static deleteAllData(): void
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
web
.
WebStorage
.
deleteAllData
();
@
Entry
@
Component
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
build
()
{
Column
()
{
Button
(
'
deleteAllData
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
deleteAllData
();
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
```
```
### deleteOrigin<sup>9+</sup>
### deleteOrigin<sup>9+</sup>
...
@@ -2592,8 +2741,22 @@ static deleteOrigin(origin : string): void
...
@@ -2592,8 +2741,22 @@ static deleteOrigin(origin : string): void
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
origin
:
string
=
"
origin
"
;
@
Entry
web
.
WebStorage
.
deleteOrigin
(
origin
);
@
Component
struct
WebComponent
{
controller
:
WebController
=
new
WebController
();
origin
:
string
=
"
origin
"
;
build
()
{
Column
()
{
Button
(
'
getHttpAuthCredentials
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
deleteOrigin
(
this
.
origin
);
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
```
```
### getOrigins<sup>9+</sup>
### getOrigins<sup>9+</sup>
...
@@ -2610,18 +2773,33 @@ static getOrigins(callback: AsyncCallback<Array<[WebStorageOrigin](#webstorageor
...
@@ -2610,18 +2773,33 @@ static getOrigins(callback: AsyncCallback<Array<[WebStorageOrigin](#webstorageor
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
web
.
WebStorage
.
getOrigins
((
error
,
origins
)
=>
{
@
Entry
if
(
error
)
{
@
Component
console
.
log
(
'
error:
'
+
error
);
struct
WebComponent
{
return
;
controller
:
WebController
=
new
WebController
();
}
origin
:
string
=
"
origin
"
;
for
(
let
i
=
0
;
i
<
origins
.
length
;
i
++
)
{
build
()
{
consloe
.
log
(
'
origin:
'
+
origins
[
i
].
origin
);
Column
()
{
console
.
log
(
'
usage:
'
+
origins
[
i
].
usage
);
Button
(
'
getOrigins
'
)
console
.
log
(
'
quota:
'
+
origins
[
i
].
quota
);
.
onClick
(()
=>
{
web
.
WebStorage
.
getOrigins
((
error
,
origins
)
=>
{
if
(
error
)
{
console
.
log
(
'
error:
'
+
error
);
return
;
}
for
(
let
i
=
0
;
i
<
origins
.
length
;
i
++
)
{
console
.
log
(
'
origin:
'
+
origins
[
i
].
origin
);
console
.
log
(
'
usage:
'
+
origins
[
i
].
usage
);
console
.
log
(
'
quota:
'
+
origins
[
i
].
quota
);
}
})
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
}
)
}
```
```
### getOrigins<sup>9+</sup>
### getOrigins<sup>9+</sup>
static getOrigins() : Promise
<Array
<[
WebStorageOrigin
](
#webstorageoriginsup9sup
)
>
>
static getOrigins() : Promise
<Array
<[
WebStorageOrigin
](
#webstorageoriginsup9sup
)
>
>
...
@@ -2637,17 +2815,32 @@ static getOrigins() : Promise<Array<[WebStorageOrigin](#webstorageoriginsup9sup)
...
@@ -2637,17 +2815,32 @@ static getOrigins() : Promise<Array<[WebStorageOrigin](#webstorageoriginsup9sup)
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
web.WebStorage.getOrigins()
@
Entry
.then(origins => {
@
Component
for (let i = 0; i < origins.length; i++) {
struct
WebComponent
{
consloe.log('origin: ' + origins[i].origin);
controller
:
WebController
=
new
WebController
();
console.log('usage: ' + origins[i].usage);
origin
:
string
=
"
origin
"
;
console.log('quota: ' + origins[i].quota);
build
()
{
Column
()
{
Button
(
'
getOrigins
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
getOrigins
()
.
then
(
origins
=>
{
for
(
let
i
=
0
;
i
<
origins
.
length
;
i
++
)
{
console
.
log
(
'
origin:
'
+
origins
[
i
].
origin
);
console
.
log
(
'
usage:
'
+
origins
[
i
].
usage
);
console
.
log
(
'
quota:
'
+
origins
[
i
].
quota
);
}
})
.
catch
(
error
=>
{
console
.
log
(
'
error:
'
+
error
);
})
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
})
}
.catch(error => {
console.log('error: ' + error);
})
```
```
### getOriginQuota<sup>9+</sup>
### getOriginQuota<sup>9+</sup>
...
@@ -2665,14 +2858,28 @@ static getOriginQuota(origin : string, callback : AsyncCallback<number>) : void
...
@@ -2665,14 +2858,28 @@ static getOriginQuota(origin : string, callback : AsyncCallback<number>) : void
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
origin: string = "origin";
@
Entry
web.WebStorage.getOriginQuota(origin, (error, quota) => {
@
Component
if (error) {
struct
WebComponent
{
console.log('error: ' + error);
controller
:
WebController
=
new
WebController
();
return;
origin
:
string
=
"
origin
"
;
build
()
{
Column
()
{
Button
(
'
getOriginQuota
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
getOriginQuota
(
this
.
origin
,
(
error
,
quota
)
=>
{
if
(
error
)
{
console
.
log
(
'
error:
'
+
error
);
return
;
}
console
.
log
(
'
quota:
'
+
quota
);
})
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
consloe.log('quota: ' + quota);
}
})
```
```
### getOriginQuota<sup>9+</sup>
### getOriginQuota<sup>9+</sup>
...
@@ -2694,13 +2901,28 @@ static getOriginQuota(origin : string) : Promise<number>
...
@@ -2694,13 +2901,28 @@ static getOriginQuota(origin : string) : Promise<number>
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
web.WebStorage.getOriginQuota()
@
Entry
.then(quota => {
@
Component
consloe.log('quota: ' + quota);
struct
WebComponent
{
})
controller
:
WebController
=
new
WebController
();
.catch(error => {
origin
:
string
=
"
origin
"
;
console.log('error: ' + error);
build
()
{
})
Column
()
{
Button
(
'
getOriginQuota
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
getOriginQuota
(
this
.
origin
)
.
then
(
quota
=>
{
console
.
log
(
'
quota:
'
+
quota
);
})
.
catch
(
error
=>
{
console
.
log
(
'
error:
'
+
error
);
})
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
```
```
### getOriginUsage<sup>9+</sup>
### getOriginUsage<sup>9+</sup>
...
@@ -2718,14 +2940,28 @@ static getOriginUsage(origin : string, callback : AsyncCallback<number>) : void
...
@@ -2718,14 +2940,28 @@ static getOriginUsage(origin : string, callback : AsyncCallback<number>) : void
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
origin: string = "origin";
@
Entry
web.WebStorage.getOriginUsage(origin, (error, usage) => {
@
Component
if (error) {
struct
WebComponent
{
console.log('error: ' + error);
controller
:
WebController
=
new
WebController
();
return;
origin
:
string
=
"
origin
"
;
build
()
{
Column
()
{
Button
(
'
getOriginUsage
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
getOriginUsage
(
this
.
origin
,
(
error
,
usage
)
=>
{
if
(
error
)
{
console
.
log
(
'
error:
'
+
error
);
return
;
}
consloe
.
log
(
'
usage:
'
+
usage
);
})
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
consloe.log('usage: ' + usage);
}
})
```
```
### getOriginUsage<sup>9+</sup>
### getOriginUsage<sup>9+</sup>
...
@@ -2747,13 +2983,28 @@ static getOriginUsage(origin : string) : Promise<number>
...
@@ -2747,13 +2983,28 @@ static getOriginUsage(origin : string) : Promise<number>
```
ts
```
ts
// xxx.ets
// xxx.ets
import
web
from
'
@ohos.web
'
;
import
web
from
'
@ohos.web
'
;
web.WebStorage.getOriginUsage()
@
Entry
.then(usage => {
@
Component
consloe.log('usage: ' + usage);
struct
WebComponent
{
})
controller
:
WebController
=
new
WebController
();
.catch(error => {
origin
:
string
=
"
origin
"
;
console.log('error: ' + error);
build
()
{
})
Column
()
{
Button
(
'
getOriginQuota
'
)
.
onClick
(()
=>
{
web
.
WebStorage
.
getOriginUsage
(
this
.
origin
)
.
then
(
usage
=>
{
console
.
log
(
'
usage:
'
+
usage
);
})
.
catch
(
error
=>
{
console
.
log
(
'
error:
'
+
error
);
})
})
Web
({
src
:
'
https://webkit.org/demos/sticky-notes/index.html
'
,
controller
:
this
.
controller
})
.
databaseAccess
(
true
)
}
}
}
```
```
## WebStorageOrigin<sup>9+</sup>
## WebStorageOrigin<sup>9+</sup>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录