1、拉包
npm install speak-tts
2、在页面中引入
import Speech from 'speak-tts' // es6
3、初始化以及实现
data () {
return {
speech:null
}
},
mounted(){
this.speechInit()
},
methods:{
speechInit(){
this.speech = new Speech()
this.speech.setLanguage('zh-CN')
this.speech.init().then(()=>{
})
},
//播放按钮
play(){
this.speech.speak({text:"收款203230元"}).then(()=>{
console.log("读取成功")
})
}
}