的index.htmlES6模块支撑在Chrome 62 /铬金丝雀64,不会局部工作,CORS错误
<html>
<head>
<script type="module">
import {answer} from './code.js'
console.info("It's ${answer()} time!")
</script>
</head>
<body>
</body>
</html>
code.js
export function answer(){
return 'module';
}
Error: Access to Script at 'file:///C:*******/es6/code.js' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.
铬说,它可以支持模块我看到了一些在网络上工作的例子,但是当我将它们复制下载并在本地运行时,我总是得到上面的错误。我不想使用Babel,Webpack等。
我曾尝试在Chrome和Chrome Canary中启用实验性Web平台功能标志。
谢谢亚历山大! 任何想法如果我尝试使用电子会发生什么? –
@markpavlis我猜想Electron没有这样的安全限制,但我不确定。 –