1 Star 0 Fork 0

tarxyz / vue-购物车案例

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

慕课网vue-购物车案例

成品展示

GIF

vue核心代码

window.vm = new Vue({
    el: "#app"
    , data: {
        showModal: false
        , productList: []
        , totalMoney: 0
        , checkAll: false
        , currentProduct: ""
    }
    , mounted: function () {
        var _this = this;
        this.cartView();
    }
    , filters: {
        formatMoney: function (value, quentity) {
            if(!quentity){
                quentity = 1;
            }
            return "¥ "+ (value * quentity).toFixed(2) + "";
        }
    }
    , methods: {
        cartView: function () {
            this.$http.get("data/cartData.json").then(function (response) {
                var res = response.data;
                if(res && res.status == '1'){
                    this.productList = res.result.list;
                    this.calcTotalMoney();
                }
            });
        }
        , selectAll: function (isCheck) {
            this.checkAll = isCheck;
            this.productList.forEach(function (item) {
                if(typeof item.checked == "undefined"){
                    $.set(item, "checked", isCheck);
                }else{
                    item.checked = isCheck;
                }
            })
            this.calcTotalMoney();
        }
    }
});

页面调用

<!--参数绑定-->
v-bind:class="{'check':product.checked}" v-on:click="selectedProduct(product)"

<!--总金额 filters格式化-->
<div class="item-price-total">
  {{product.productPrice | formatMoney(product.productQuentity)}}
</div>

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/tarxyz/vue-checkout.git
git@gitee.com:tarxyz/vue-checkout.git
tarxyz
vue-checkout
vue-购物车案例
master

搜索帮助