vue 微信浏览器ios系统

1、ios <audio>不播放
Vue.prototype.playAudio = function (audioSrc, cb) { var audio = new Audio() audio.preload = ‘auto‘ audio.src = audioSrc if (window.WeixinJSBridge) { console.log(‘audio支持‘) WeixinJSBridge.invoke(‘getNetworkType‘, {}, function (e) { audio.load() audio.play() }, false) } else { console.log(‘audio不支持‘) document.addEventListener("WeixinJSBridgeReady", function () { WeixinJSBridge.invoke(‘getNetworkType‘, {}, function (e) { audio.load() audio.play() }) }, false) } cb && cb(audio) }

  

2、预加载图片
beforeCreate () {
      const cdnUrl = ‘https://xxx/image‘
      let imgs = [
        `${cdnUrl}/home-bg.gif`,
        `${cdnUrl}/btn-close.png`,
        `${cdnUrl}/hand-down.png`,
      ]
      imgs.forEach((item) => {
        let image = new Image()
        image.src = item
        image.onload = () => {
          this.count++
        }
      })
  },

  

    /**scroll隐藏底部 */
    hideBtBox () {
      var that = this
      window.onscroll = function(){
        var scrollTop = document.documentElement.scrollTop||document.body.scrollTop //滚动高
        var windowHeight = document.documentElement.clientHeight || document.body.clientHeight //视图高
        var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight //文档高
        if ((scrollTop + windowHeight + 30) >= scrollHeight) {
          that.isShowBt = false
        } else {
          that.isShowBt = true
        }
      }
    },

  

vue 微信浏览器ios系统<audio>不播放,图片预加载,scroll隐藏底部笔记

上一篇:小程序结构调整之使用async和await笔记


下一篇:和大家交流一下微信IPAD安卓协议源码