Index.htmlとES6モジュールのサポート、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.
Chromeはそれがモジュールをサポートできると言いますWeb上で動作するサンプルを見たことがありますが、それらをコピーしてローカルで実行すると、私は常に上記のエラーが発生します。
ChromeとChrome Canaryの両方でExperimental Web Platformの機能フラグを有効にしようとしました。
ありがとうアレキサンダー!!! 私は電子を使用しようとするとどうなるでしょうか? –
@markpavlis私はエレクトロンがそのようなセキュリティ制限を持っていないと思うだろうが、わからない。 –