的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沒有這樣的安全限制,但我不確定。 –