为了账号安全,请及时绑定邮箱和手机立即绑定

Uncaught (in promise) TypeError: Cannot read property 'result' of undefined

_this.productList = res.body.result.list;报错,Uncaught (in promise) TypeError: Cannot read property 'result' of undefined,请问是怎么回事


完整代码如下:

var vm = new Vue({

el:"#app",

data:{

totalMoney:0,

productList:[]

},

filters:{


},

mounted:function(){

this.$nextTick(function(){

this.cartView();

})

},

methods:{

cartView:function(){

var _this = this;

this.$http.get("data/cartData.json",{"id":123}).then(function(res){

_this.productList = res.body.result.list;

_this.totalMoney = res.body.result.totalMoney;

});

}

    }

});


正在回答

2 回答

我在chrome里面调试的,应该是res.data.result.list和res.data.result.totalMoney

1 回复 有任何疑惑可以回复我~
#1

行走的指尖 提问者

嗯嗯,我知道啦,谢谢你
2018-03-08 回复 有任何疑惑可以回复我~

还是跨域的问题 把json文件放到html代码的目录就ok     就是要同一级目录才可以

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
使用vue2.0实现购物车和地址选配功能
  • 参与学习       96915    人
  • 解答问题       445    个

本视频教程结合案例完整贯穿各个知识点,轻松玩转vue2.0框架

进入课程

Uncaught (in promise) TypeError: Cannot read property 'result' of undefined

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信