值
一個字串,表示裝置的語言。
示例
js
for (const voice of voices) {
const option = document.createElement("option");
option.textContent = `${voice.name} (${voice.lang})`;
if (voice.default) {
option.textContent += " — DEFAULT";
}
option.setAttribute("data-lang", voice.lang);
option.setAttribute("data-name", voice.name);
voiceSelect.appendChild(option);
}
規範
| 規範 |
|---|
| Web Speech API # dom-speechsynthesisvoice-lang |
瀏覽器相容性
載入中…