老师,在attached里面this._recoverStatus()是不是多写了一遍呢
来源:10-13 真实感受Component与Model的好处

爱偷懒的小码农
2018-12-10
写回答
1回答
-
并没有呀,
你是想说,this._monitorSwitch()中已经有mMgr.onPlay(() => {this._recoverStatus()})了?
你可以把this._recoverStatus()注释了,然后播放,切换nav,然后切换回来看下,音乐实际是播放的,但图标变为pause了,
所以此处的this._recoverStatus()是用来控制切换nav时的播放图标状态的。
attached (e) {
this._recoverStatus()
this._monitorSwitch()
},
_monitorSwitch () {
mMgr.onPlay(() => {
this._recoverStatus()
})
mMgr.onPause(() => {
this._recoverStatus()
})
mMgr.onStop(() => {
this._recoverStatus()
})
mMgr.onEnded(() => {
this._recoverStatus()
})
}
012018-12-10
相似问题