1,创建一个js文件 (voicePrompt.js)

function voicePrompt (text){
    new Audio('http://tts.baidu.com/text2audio?cuid=baiduid&lan=zh&ctp=1&pdt=311&tex=' + text).play();
}

export {
    voicePrompt
}

 2在min.js

import * as voicePromptFun from './utils/voicePrompt'  
Vue.prototype.voicePrompt = voicePromptFun.voicePrompt  //语音提醒

 3在其他页面调用

this.voicePrompt('皮卡丘');

  

相关文章:

  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2021-12-14
  • 2021-11-04
  • 2021-11-26
  • 2023-02-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-05-27
  • 2021-11-17
  • 2021-08-28
相关资源
相似解决方案