this.blobToBase64(this.blob).then((stream) => { this.recordLoad = true; // 下面发送数据 uploadVoice({ attachContent: stream, }) .then((res) => { console.log("成功", res); if (res.data.code == 200) { this.questionVoice = res.data.fileName; document.getElementById("recordLoad").innerHTML="上传成功" } }) .catch((res) => { console.log("语音上传失败",res); Toast("3") // Toast("图片上传失败"); }); });不用异步
时间: 2024-02-14 10:05:33 浏览: 32
如果不使用异步,可以将代码改为以下形式:
```
this.blobToBase64(this.blob).then(function(stream) {
this.recordLoad = true;
// 下面发送数据
uploadVoice({
attachContent: stream,
})
.then(function(res) {
console.log("成功", res);
if (res.data.code == 200) {
this.questionVoice = res.data.fileName;
document.getElementById("recordLoad").innerHTML="上传成功"
}
})
.catch(function(res) {
console.log("语音上传失败",res);
Toast("3")
// Toast("图片上传失败");
});
}.bind(this));
```
或者使用箭头函数:
```
this.blobToBase64(this.blob).then((stream) => {
this.recordLoad = true;
// 下面发送数据
uploadVoice({
attachContent: stream,
})
.then((res) => {
console.log("成功", res);
if (res.data.code == 200) {
this.questionVoice = res.data.fileName;
document.getElementById("recordLoad").innerHTML="上传成功"
}
})
.catch((res) => {
console.log("语音上传失败",res);
Toast("3")
// Toast("图片上传失败");
});
});
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)