0
我有一個使用項目中其他模塊的內聯模塊腳本。 我需要調用使用的onclick從HTML模塊功能或其他一切工作..JS模塊和html之間的通信(全雙工)
<script type="module">
import * as blabla from './somemodule.js';
function myfunction(){
console.log("Youhou!");
}
//Communication from script to html works fine
document.getElementById('test').onclick = myfunction;
</script>
<button id="test">Test</button>
<button onclick="myfunction();">Test</button>//This dont work
這甚至可能嗎?在谷歌上找不到任何東西,我是一個很棒的Google員工。 非常感謝!