1. 程式人生 > >微信小程式web-view例項

微信小程式web-view例項

標題圖

微信小程式web-view例項

index.js

//index.js
//獲取應用例項
const app = getApp()

Page({

      /**
       * 頁面的初始資料
       */
      data: {

      },
      goBaidu: function(e) {
        wx.navigateTo({
          url: '../out/out', 
          success: function(e) {
console.log(e);
          }, 
          fail: function(err) {
console.log(err);
          }
        })
      },


        /**
         * 生命週期函式--監聽頁面載入
         */
        onLoad: function(options) {

          },

          /**
           * 生命週期函式--監聽頁面初次渲染完成
           */
          onReady: function() {

          },

          /**
           * 生命週期函式--監聽頁面顯示
           */
          onShow: function() {

          },

          /**
           * 生命週期函式--監聽頁面隱藏
           */
          onHide: function() {

          },

          /**
           * 生命週期函式--監聽頁面解除安裝
           */
          onUnload: function() {

          },

          /**
           * 頁面相關事件處理函式--監聽使用者下拉動作
           */
          onPullDownRefresh: function() {

          },

          /**
           * 頁面上拉觸底事件的處理函式
           */
          onReachBottom: function() {

          },

          /**
           * 使用者點選右上角分享
           */
          onShareAppMessage: function() {

          }
      })

index.wxml

<!--index.wxml-->
<view class='wrapper'>
  <button class='wepay' bindtap='goBaidu'>點選跳轉</button>
</view>

out.wxml

<web-view src="https://www.baidu.com/"></web-view>

圖1

圖2

達叔小生:往後餘生,唯獨有你
You and me, we are family !
90後帥氣小夥,良好的開發習慣;獨立思考的能力;主動並且善於溝通
簡書部落格: 達叔小生

https://www.jianshu.com/u/c785ece603d1

結語

  • 下面我將繼續對 其他知識 深入講解 ,有興趣可以繼續關注
  • 小禮物走一走 or 點贊