<div class="card-header">
<h2 th:text="${word.getWordName()}">日语N3 </h2>
<button onclick="playAudio()" th:text="${word.getAudio()}" >[apple]</button>
<audio id='audioPlay' src='http://dict.youdao.com/dictvoice?le=jap&audio=けんさ&type=3' th:value="${word.getWordName()}"/>
</div>
<script th:inline="javascript">
function playAudio(){
//得到读音名字
var word=[[${word.getWordName()}]];
console.log(word);
//改变读音地址
document.getElementById('audioPlay').src='http://dict.youdao.com/dictvoice?le=jap&type=3&audio='+word;
document.getElementById('audioPlay').play();
}
</script>
有道词典在线发音API
http://dict.youdao.com/dictvoice?le=jap&type=3
目前网上大多是英语 所以记录一下日语发音API
英语发音请查看 :英语在线发音API