用于在设备端上展现浏览器网页内容的组件。
# demo
# props
名称 | 类型 | 默认值 | 可选值 | 必填 | 描述 |
---|---|---|---|---|---|
url | string | - | - | 是 | webview 浏览器的资源地址(需要是 https |
ua | string | - | - | 否 | webview 浏览器的用户代理 |
scale | string | '100%' | - | 否 | webview 浏览器缩放百分比 |
title | string | - | - | 否 | webview 浏览器标题 |
controls | boolean | false | - | 否 | 是否展示 webview 控制栏(包含title) |
controlBarPosition | string | absolute | absolute、static | 否 | webview 控制栏展现方式(absolute: 随滑动动作隐藏,滑动静止展现, static: 始终展现,不消失) |
# events
名称 | 参数 | 参数说明 | event说明 |
---|---|---|---|
onPageStart | - | - | 浏览器资源页面开始加载(仅在当前页面第一次资源加载时触发) |
onPageFinish | - | - | 浏览器资源页面加载完成(仅在当前页面第一次资源加载完成时触发) |
onLoaded | - | - | 组件加载完成后可触发该事件(仅在组件第一次或重新渲染完成时触发) |
onExit | e | event | 点击控制栏退出按钮时触发该事件 |
# methods
可以通过 InvokeMethod 指令调用的组件方法:
方法名 | 参数 | 参数说明 | 方法描述 |
---|
# 组件样例(example)
{
"type": "WebView",
"componentId": "example-webview",
"styles": {
"width": "100%",
"flex": 1
},
"props": {
"url": "https://m.baidu.com/",
"scale": "100%",
"controls": true,
"controlBarPosition": "absolute",
"title": "百度一下"
},
"events": {
"onPageStart": [{
"type": "SendEvent",
"componentId": "webview-compid"
}],
"onPageFinish": [{
"type": "SendEvent",
"componentId": "webview-compid"
}],
"onLoaded": [{
"type": "SendEvent",
"componentId": "webview-compid"
}],
"onExit": [{
"type": "PageDestroy",
"delay": 300,
"componentId": "webview-compid"
}]
}
}
← Timer 计时器 Video 视频播放器 →