如下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()
};
}
});
13 回答13.1k 阅读
2 回答5.3k 阅读✓ 已解决
7 回答2.2k 阅读
5 回答1.6k 阅读
2 回答1.2k 阅读✓ 已解决
4 回答1.5k 阅读✓ 已解决
5 回答1.8k 阅读✓ 已解决
又开了一个问题吗、如果是双击打开html的话是会有这个问题的、用node搭一个小型服务器启动起来就可以访问了