使用mpVue开发小程序实战总结

1.图形验证码接口返回base64格式的数据,使用image标签接收不显示问题。javascript

解决方法:vue

  使用wx.base64ToArrayBuffer和wx.arrayBufferToBase64转化一遍数据java

wx.request({
        url: `${this.$proxyTable}/declaring/authCode`,
        success:(res)=> {
          let _array = wx.base64ToArrayBuffer(res.data.data.authCode);
          let _base64 = wx.arrayBufferToBase64(_array);
          this.imgSrc = 'data:image/jpeg;base64,' + _base64;
          this.imgSrcKey = res.data.data.authCodeKey;
        }
      })

  

2.navigateTo跳转的页面返回到上一页面再回到当前页时数据不刷新。vuex

解决方法:小程序

  使用小程序原生钩子onShow()代替created()。函数

 

3.页面之间传参问题。this

解决方法:url

  1.使用url方式:在目标页面使用onLoad(query)钩子函数中经过query获取。blog

  2.本地存储:使用wx.getStorageSync()和wx.getStorageSync()传递。接口

  3.使用vuex:在目标页面引入store,经过store.state.xxx获取

相关文章
相关标签/搜索