我是靠谱客的博主 聪明大神,这篇文章主要介绍微信小程序报错Uncaught (in promise) AbortError: The play() request was interrupted by a call to pause().,现在分享给大家,希望可以做个参考。
主要原因:
调用接口,并且接着使用返回的数据操作,因为调接口是耗时的,你的及时操作提前
解决办法:
加定时器延迟执行操作,延时时间太少了也不行,自己测试后50毫秒可以
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23// 播放 play:function(){ var that = this //下面的代码是关键 setTimeout(function(){ that.audioCtx.play() that.setData({state:'running'}) },50) }, //暂停 pause:function(){ this.audioCtx.pause() this.setData({state:'paused'}) }, //下一首 next:function(){ var index = this.data.playIndex >= this.data.playlist.length-1 ? 0 : this.data.playIndex+1 this.setMusic(index) if(this.data.state == 'running'){ this.play() } }
最后
以上就是聪明大神最近收集整理的关于微信小程序报错Uncaught (in promise) AbortError: The play() request was interrupted by a call to pause().的全部内容,更多相关微信小程序报错Uncaught内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复