美文网首页
本地html引入export的方法

本地html引入export的方法

作者: WWWWWWWWWWWWWWM | 来源:发表于2021-09-15 09:07 被阅读0次

引入要注意两个方面

  • 第一,要在script加入type="module"
 <script type="module">
        import {aaa} from '.a.js';
        console.log(aaa)
    </script>
  • 第二,引入后直接打开浏览器会报跨域,是因为type="module"会跨域,解决方法开启一个服务打开就可以了,比如用open with live server

相关文章

网友评论

      本文标题:本地html引入export的方法

      本文链接:https://www.haomeiwen.com/subject/clrkgltx.html