美文网首页Web前端之路
Chrome61新功能之ES6 moudles

Chrome61新功能之ES6 moudles

作者: 天云白 | 来源:发表于2017-10-10 23:49 被阅读21次

ES6 moudles功能

https://developers.google.com/web/updates/2017/09/nic61#modules

chrome浏览器输入 chrome:flags

开启 Experimental Web Platform

image.png

index.html

<script type="module">
  // or an inline script
  import {helperMethod} from './providesHelperMethod.js';
  helperMethod();
</script>
<h1>module test</h1>

�新建providesHelperMethod.js

// providesHelperMethod.js
export function helperMethod() {
  console.info(`I'm helping!`);
}

更多例子参考

在Chrome打开本地文件如果引入js会有如下错误提示

image.png

处理有以下两种方法

  • 命令行选项启动

open /Applications/Google\ Chrome.app --args --allow-file-access-from-files

  • 本地服务器

python -m SimpleHTTPServer 8000

image.png

Chrome中打开http://127.0.0.1:8000/index.html即可。

控制台 await操作

https://developers.google.com/web/updates/2017/08/devtools-release-notes

Console中输入如下:

await fetch('https://httpbin.org/get?a=1')

image.png

相关文章

网友评论

    本文标题:Chrome61新功能之ES6 moudles

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