1.  遇到问题:如下代码第17行,获取本地json文件,如果直接在浏览器中打开引用该文件的.html文件,在chrme浏览器中并不能读取到json文件。

 var vm=new Vue({
el:"#app",
data:{
totalMoney:0,
productList:[]
},
filters:{ },
mounted:function () {
this.cartview();
},
methods:{ cartview:function(){
var _this=this;
this.$http.get("data/cartData.json").then(function(res){
_this.productList=res.data.result.list;
_this.totalMoney=res.data.result.totalMoney;
});
}
} });

浏览器错误提示:

2.  原因:chrome浏览器为了安全性考虑,默认对跨域访问禁止。

3.  解决方案:运用SublimeServer

(1)安装:

  sublime编辑器:perferences——packageControl——输入:Install Package——SublimeServer——进行安装。

(2)在Tools下可以查看到:SublimeServer——start SublimeServer

(3)到相应的页面——右键——view in sublimeServer

注意:  

  这时可能会出现问题:

    eg: File cart.html not in sublilme Project Folder!   

这是因为SublimeServer要求代码文件必须添加到Sublime Text的项目里:Porject——Add Folder to Project ——选择你的项目文件夹。

(4)再次执行步骤(3)

此时在控制台看到可以正常加载json文件。

另:

在Tools——SublimeServe——settings——查看SublimeServer的基本配置,可以设置修改服务器端口,文件扩展名等。

Sublime_SublimeServer的更多相关文章

随机推荐

  1. CentOS6.9安装HDFS

    1.安装依赖包 yum install -y gcc openssh-clients 2.升级glib2.14 升级glibc-2.14用到的rpm 下载地址:https://pan.baidu.co ...

  2. 修改Elasticsearch的settings

    解决:Limit of total fields [1000] in index [nginx-access-log] has been exceeded" 的问题 PUT http://1 ...

  3. Understanding about numerical stability, convergence and consistency

    In a computer simulation of the real world, physical quantities, which usually have continuous distr ...

  4. 通俗理解webService及.net中的使用方法

    什么是WebService? WebService两个关键字:HTTP.接口 WebService就是一个接口,与普通接口的区别就是:普通接口只能本地调用:WebService可以远程调用. WebS ...

  5. Kudu之Tablet的发现过程

    当创建Kudu客户端时,其会从主服务器上获取tablet位置信息,然后直接与服务于该tablet的服务器进行交谈.为了优化读取和写入路径,客户端将保留该信息的本地缓存,以防止他们在每个请求时需要查询主 ...

  6. app奔溃经验和应对方式

    bug直接影响:用户体验.app商店评级.用户忠诚度 前言: 因为现在市场是andriod手机的碎片化.造成了andriod手机更加容易出现APP的崩溃,通常在网络异常时APP上还在进行数据交互,即会 ...

  7. Codeforces 542E Playing on Graph 其他

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF542E.html 题目传送门 - CF542E 题目传送门 - 51Nod1481 题意 有一幅无向图,它有 ...

  8. linux中通过lsof恢复删除的文件,前题是fd被占用。

    http://www.serverwatch.com/tutorials/article.php/3822816/Recovering-Deleted-Files-With-lsof.htm One ...

  9. css上传图片中等待不可点击效果

    <!DOCTYPE html> <html> <head> <title>上传中</title> <style type=" ...

  10. Mybatis if test 中int integer判断非空的坑

    Mybatis 中,alarmType 是int类型.如果alarmType 为0的话,条件判断返回结果为false,其它值的话,返回true. 1 <if test="alarmTy ...