web-view
微信小程序:
承載網頁的容器。會自動鋪滿整個小程序頁面,個人類型的小程序暫不支持使用。
其中一些具體的屬性和接口,可以看微信小程序官方文檔
https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html
一個簡單的demo
wxml文件
<web-view src="https://www.baidu.com/"></web-view>
效果:
支付寶小程序:
html
<!-- API-DEMO page/component/webview/webview.axml --> <view class="page"> <web-view src="https://render.alipay.com/p/s/web-view/index" onMessage="onmessage"></web-view> </view>
js
// API-DEMO page/component/webview/webview.js
Page({
data: {},
onShareAppMessage(options) {
my.alert({content:JSON.stringify(options.webViewUrl)});
return {
title: '分享 web-View 組件',
desc: 'View 組件很通用',
path: 'page/component/component-pages/webview/baidu',
'web-view': options.webViewUrl,
};
},
onmessage(e){
my.alert({
content: '拿到數據'+JSON.stringify(e), // alert 框的標題
});
}
});
具體屬性可以看官方文檔:
