如下3种方法:
1、 搭建本地webserver,比如webstorm自带webserver
2、 通过配置浏览器访问本地文件
给chrome加上启动参数:
--allow-file-access-from-files 或 --disable-web-security
谷歌浏览器快捷方式,右键属性将目标位置中加上启动参数
C:\Users\xxx\AppData\Local\Google\Chrome\Application\chrome.exe --disable-web-security
3、 使用mock数据,兼容jquery ajax接口
https://github.com/jakerella/...
$.mockjax({
url: "/restful/webservice",
dataType: "json",
response: function(settings) {
this.responseText = {
randomText: "random " + Math.random()
};
}
});
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
4 回答4.4k 阅读✓ 已解决
4 回答3.8k 阅读✓ 已解决
又开了一个问题吗、如果是双击打开html的话是会有这个问题的、用node搭一个小型服务器启动起来就可以访问了