javascript 如何导入 npm 包

发布时间: 更新时间: 总字数:73 阅读时间:1m 作者: IP属地: 分享 复制网址

Html 通过 <script type="text/javascript"> 可以导入 js 包,我们也可以通过 <script type="module"> 导入 NPM 包。

使用示例

github/hotkey包导入为例:

  <script type="module">
    import {install} from '/js/github-hotkey/index.esm.js'

    // Install all the hotkeys on the page
    for (const el of document.querySelectorAll('[data-hotkey]')) {
      install(el)
    }
  </script>
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数