Chrome61新功能之ES6 moudles

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容