优化后的代码:

if(this.form.content === '') { this.$modal.msgError('请输入内容'); return false; }

if(this.form.voiceName === '') { this.$modal.msgError('请选择音色'); return false; }

this.getTtsToAudio(); // this.audioData ? this.handlePlay() : this.getTtsToAudio();

将两个 if 语句合并为两个独立的 if 语句,并在最后调用 getTtsToAudio() 函数。去掉了注释掉的代码,因为该代码没有用到。

优化代码 ifthisformcontent === this$modalmsgError请输入内容 return false else ifthisformvoiceName === this$modalmsgError请选择音色 return false else thisa

原文地址: https://www.cveoy.top/t/topic/bAbg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录