vue用到H5+的录音功能 真机模拟的时候不能实现录音,报错plusready is not undefined 但是官方的demo中audio文件在真机模拟的时候是能够实现录音的。
export default {
data(){
return {
r: ' '
}
},
created(){
this.load()
},
methods: {
load(){
if(window.plus){
this.plusReady();
}else{
document.addEventListener('plusready', this.plusReady, false);
}
},
// 扩展API加载完毕,现在可以正常调用扩展API
plusReady() {
this. r = plus.audio.getRecorder();
},
startRecord() {
if (this.r == null) {
alert("Device not ready!");
return;
}
r.record({filename: "_doc/audio/"}, ()=> {
alert("Audio record success!");
}, (e)=> {
alert("Audio record failed: " + e.message);
});
},
stopRecord() {
this.r.stop();
},
},
components: {Mheader}
}