首页 > 解决方案 > 如何在 vue 组件中实现 typescript 代码?

问题描述

https://github.com/bradmartin/nativescript-texttospeech

texttospeech 有用 TS 编写的文档。

如何将代码翻译成ns-VUE?

import { TNSTextToSpeech, SpeakOptions } from 'nativescript-texttospeech';

let TTS = new TNSTextToSpeech();

let speakOptions: SpeakOptions = {
  text: 'hello world',
};

TTS.speak(speakOptions); 

我不想使用打字稿,我只需要一个在 Nativescript-Vue 中说话的按钮。

提前致谢

标签: typescriptvue.jsnativescript-vue

解决方案


只需从 中删除类型speakOptions并将其从导入中删除:

import { TNSTextToSpeech } from 'nativescript-texttospeech';

let TTS = new TNSTextToSpeech();

let speakOptions = {
  text: 'hello world',
};

TTS.speak(speakOptions); 

推荐阅读