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 } } },