我试着用追踪器。但是,当我想加载一个模块时,我会得到一个错误,表明它没有成功。我的代码基于它在模块文档中提供的示例跟踪。
下面是main.html:
<script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<script>
System.traceurOptions = { experimental: true }
</script>
<script type="module" src="ProfileView.js"></script>加载模块:
// ProfileView.js
import {firstName, lastName, year} from './Profile.js';
function setHeader(element) {
element.textContent = firstName + ' ' + lastName;
}
// rest of module// Profile.js
export var firstName = 'David';
export var lastName = 'Belle';
export var year = 1973;我在Chrome中得到了以下错误:
file:///C:/Code/Tests/Traceur/ProfileView.js.不能加载XMLHttpRequest跨源请求仅支持协议方案: http、data、chrome、chrome https、https、chrome-。file:///C:/Code/Tests/Traceur/ProfileView.js未加载NetworkError:未能在‘XMLHttpRequest’上执行'send‘:未能加载'file:///C:/Code/Tests/Traceur/ProfileView.js'.
我知道您不能通过文件系统发出xhr请求,但是我看到了一些教程,其中代码的结构与我的类似,它在那里工作.
我可能做错什么了?
发布于 2015-08-02 18:01:07
您不能使用xhr访问文件系统,您应该通过运行本地over服务器通过http打开这些页面。如果您真的想启用文件系统访问,可以:http://www.chrome-allow-file-access-from-file.com/
也就是说,启动铬chrome.exe chrome.exe
https://stackoverflow.com/questions/31774814
复制相似问题