个人觉得既然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
new Vue({
el:'#app',
data:{
title:"hello vue"
},
filters:{
},
mounted:function(){
this.cartView();
},
methods:{
cartView:function(){
this.title="Vue Hello";
}
}
});
el:'#app',
data:{
title:"hello vue"
},
filters:{
},
mounted:function(){
this.cartView();
},
methods:{
cartView:function(){
this.title="Vue Hello";
}
}
});
2017-11-22