代码在这
https://github.com/BUPTlhuanyu/vueShoppingCar
欢迎clone,喜欢的给star哦
之后还会给出基于该项目利用webpack和vue实现组件化
https://github.com/BUPTlhuanyu/vueShoppingCar
欢迎clone,喜欢的给star哦
之后还会给出基于该项目利用webpack和vue实现组件化
2017-11-29
图片还是没加载出来,图片的地址为:<img src="static/img/goods-2.jpg" alt="图片加载不成功!">
2017-11-28
为毛是这个结果
Error in mounted hook: "TypeError: Cannot read property 'get' of undefined"
Error in mounted hook: "TypeError: Cannot read property 'get' of undefined"
2017-11-28
this.$http.get('./data/cartData.json',{'id':123}).then(function(res){
_this.productList = res.data.result.list;
console.log(_this.productList)
为什么成品项目里面res.data.result.list 这个要加data才能渲染出效果,讲案例的时候不用呢?
_this.productList = res.data.result.list;
console.log(_this.productList)
为什么成品项目里面res.data.result.list 这个要加data才能渲染出效果,讲案例的时候不用呢?
2017-11-27
changeMoney:function(product, way){
product.productQuantity+=way;
}
product.productQuantity+=way;
}
2017-11-27
个人觉得既然2.0版本已经把1.0的知识点都覆盖了,就没必要再讲1.0那些错误的示范了,这让没接触过vue的小伙伴很痛苦,还有那个结账那里不需要做个判断?如果没选择商品跳去结账页也没用吧?
2017-11-27
checkAll: function(type){
this.checkedAllFlag = type
this.list.forEach(function(value, index){
if (type) {
value.checked = true;
}else{
value.checked = false;
}
})
}
this.checkedAllFlag = type
this.list.forEach(function(value, index){
if (type) {
value.checked = true;
}else{
value.checked = false;
}
})
}
2017-11-27
checkOne: function(item){
if (typeof item.checked == 'undefined') {
this.$set(item, 'checked', true)
}else{item.checked = !item.checked};
var _this = this;
for (var i = 0; i < this.list.length; i++) {
if (this.list[i].checked) {_this.checkedAllFlag = true}else{_this.checkedAllFlag = falsebreak;}}}
if (typeof item.checked == 'undefined') {
this.$set(item, 'checked', true)
}else{item.checked = !item.checked};
var _this = this;
for (var i = 0; i < this.list.length; i++) {
if (this.list[i].checked) {_this.checkedAllFlag = true}else{_this.checkedAllFlag = falsebreak;}}}
2017-11-27
针对杨少峰同学的提出的解决方案还是有一个bug,如果从最后一个开始选,全部选中仍然会被勾选,是因为没有break导致,不用forEach
for (var i = 0; i < this.productList.length; i++) {
if (this.productList[i].checked) {
_this.checkedAllFlag = true;
}else{
_this.checkedAllFlag = false;
break;
}
}
for (var i = 0; i < this.productList.length; i++) {
if (this.productList[i].checked) {
_this.checkedAllFlag = true;
}else{
_this.checkedAllFlag = false;
break;
}
}
2017-11-27
computed:{
filterAddress:function () {
return this.addressList.slice(0,this.offset);
/*
注意splice 方法方法会修改原对象!!!!!!!!!!!
slice 方法不会!!!!!!!!!!
*/
}
},
filterAddress:function () {
return this.addressList.slice(0,this.offset);
/*
注意splice 方法方法会修改原对象!!!!!!!!!!!
slice 方法不会!!!!!!!!!!
*/
}
},
2017-11-26