關於小程序的內嵌其他網頁


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 框的標題
    });
  }
});

  

具體屬性可以看官方文檔:

https://docs.alipay.com/mini/component/web-view


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM