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