且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 HTML 中的 JavaScript 模块调用函数

更新时间:2022-12-16 15:29:53

可以在全局window对象上定义函数:

You can define the function on the global window object:

<script type="module">

  window.greet = function () {
    alert('Hello')
  }

</script>

<button onclick="greet()">Hello</button>