如何将 typescript 代码实现到 vue 组件中?
How to implement typescript code into vue component?
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 中对话的按钮。
提前致谢
只需从 speakOptions
中删除类型并将其从导入中删除:
import { TNSTextToSpeech } from 'nativescript-texttospeech';
let TTS = new TNSTextToSpeech();
let speakOptions = {
text: 'hello world',
};
TTS.speak(speakOptions);
如果其他人正在尝试将 TS 转换为 vanilla JS,请尝试 TypeScript Playground
这就是我想要做的。
<template>
<Page>
<ActionBar title="Welcome" />
<StackLayout>
<Label class="message" :text="speakOptions.text" col="0" row="0" />
<Button text="talk" @tap="talk('welcome')" />
</StackLayout>
</Page>
</template>
<script >
import { TNSTextToSpeech } from "nativescript-texttospeech";
let TTS = new TNSTextToSpeech();
export default {
data() {
return {
speakOptions: {
text: "hello"
}
};
},
methods: {
talk: function(message) {
this.speakOptions.text = message;
TTS.speak(this.speakOptions);
}
}
};
</script>
<style scoped>
</style>
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 中对话的按钮。
提前致谢
只需从 speakOptions
中删除类型并将其从导入中删除:
import { TNSTextToSpeech } from 'nativescript-texttospeech';
let TTS = new TNSTextToSpeech();
let speakOptions = {
text: 'hello world',
};
TTS.speak(speakOptions);
如果其他人正在尝试将 TS 转换为 vanilla JS,请尝试 TypeScript Playground
这就是我想要做的。
<template>
<Page>
<ActionBar title="Welcome" />
<StackLayout>
<Label class="message" :text="speakOptions.text" col="0" row="0" />
<Button text="talk" @tap="talk('welcome')" />
</StackLayout>
</Page>
</template>
<script >
import { TNSTextToSpeech } from "nativescript-texttospeech";
let TTS = new TNSTextToSpeech();
export default {
data() {
return {
speakOptions: {
text: "hello"
}
};
},
methods: {
talk: function(message) {
this.speakOptions.text = message;
TTS.speak(this.speakOptions);
}
}
};
</script>
<style scoped>
</style>