动态修改全局page样式

const myPage = Page
Page = function (e) {
  let {
    onLoad
  } = e
  e.onLoad = (() => {
    return function (res) {
      wx.setPageStyle({
        style: {
          background: '#ccc'
        },
        success(e) {
          console.log(e)
        },
        fail(e) {
          console.log(e)
        }
      })
      // this为页面实例
      console.log('overWrite onLoad:', res, this)
      onLoad && onLoad.call(this, res)
    }
  })()
  return myPage.call(this, e)
}

 

posted @ 2020-11-30 18:19  黑客PK  阅读(545)  评论(0编辑  收藏  举报