您好,【】wx.createSelectorQuery()返回的结果是null 微信小程序开发。我现在遇到了一个问题。我在两个页面index和detail页面的page上边声明了两个const recorderManager = wx.getRecorderManager();然后在各自的onload中声明了onstop事件,现在出现了一个问题程序启动进入首页(index页)以后,在进入detail页面,再回到首页,进行录音此时录音结束以后的onstop执行的却是detail页面的事件,不知道该如何处理,麻烦指导下谢谢//index.js//获取应用实例const app = getApp()const recorderManager = wx.getRecorderManager();const innerAudioContext = wx.createInnerAudioContext();var util = require('../../utils/util.js');Page({ 。。。。。。。onLoad: function (options) { var that = this; innerAudioContext.onPlay(() => { }) recorderManager.onStart(() => { }); recorderManager.onStop((res) => { console.log("首页输出")})})
上边是index的const app = getApp();const recorderManager = wx.getRecorderManager();const innerAudioContext = wx.createInnerAudioContext();var util = require('../../utils/util.js');Page({。。。。。 onLoad: function (options) { recorderManager.onStop((res) => { console.log("detail输出")})}})
微信小程序开发相关问题解答;本文来自微信小程序工厂 http://www.xcxgc.com 转载请保留。
微信小程序开发者回答:
范***:
又要沉了?
M***:
RecorderManager 和 BackgroundAudioManager 一样都是全局的,你这两个页面其实都是同一个对象。建议页面 onShow 时重新绑定各个事件,即使没用到的事件也绑一个空函数,覆盖掉之前页面绑定的其他事件。
返回距离结果 “起终点距离超长” 求大神指点#微信小程序教程 ...
范***:
谢谢您的回复,但是这样做不行,这样 话 相当于事件注册了多次,到时候监听事件会执行多次
本文网址:http://www.91bianli.com/kaifazhinan/71547.html