1、安装speak-tts包
npm install speak-tts
2、在页面中引入
import Speech from 'speak-tts'
3、初始化以及实现
data () { return { speech:null } }, mounted(){ this.speechInit(); }, methods:{ speechInit(){ this.speech = new Speech(); this.speech.setLanguage('zh-CN'); this.speech.init().then(()=>{ console.log('语音播报初始化完成...') }) }, //语音播报 speak(){ this.speech.speak({text:"语音播报测试"}).then(()=>{ console.log("播报完成...") }) } }