设置title后即可修复
// music.js
properties: {
src: String,
title: String
},
// ...省略
const mMgr = wx.getBackgroundAudioManager()
mMgr.src = this.properties.src
mMgr.title = this.properties.title
此外,classic.wxml添加一下:
<v-music
wx:if="{{classic.type==200}}"
img="{{classic.image}}"
content="{{classic.content}}"
title="{{classic.title}}"
src="{{classic.url}}" />
注意:
可能还会报一个:若需要小程序在退到后台后继续播放音频,你需要在 app.json
中配置 requiredBackgroundModes
属性,详见: https://developers.weixin.qq.com/miniprogram/dev/framework/config.html#requiredbackgroundmodes 错误
那就在外面的
app.json
里添加:
"requiredBackgroundModes": [
"audio"
],