• (28)打鸡儿教你Vue.js


    单件商品金额计算和单选全选功能

    new Vue({
     el: '#app',
     data: {
      totalMoney: 0,
      productList: []
     },
     filters: {
      formatMoney: function (value) {
       return "¥ " + value.toFixed(2);
      },
     },
     mounted: function() {
      this.$nextTick(function(){
       this.cartView();
      });
     },
     methods: {
      cartView: function() {
       let _this = this;
       this.$http.get("data/cartData.json", {"id":123}).then(res=>{
       this.productList = res.body.result.list;
       this.totalMoney = res.body.result.totalMoney;
      });
      }
     }
    });
    Vue.filter("money", function(value,type) {
     return "¥ "+value.toFixed(2) + type;
    })
    
    changeMoney: function(product, way){
    if(way>0){
     product.productQuentity++;
     }else{
     product.productQuentity--;
     if(product.productQuentity<1){
      product.productQuentity = 1;
     }
     }
    }
    
    selectedProduct: function (item) {
     if(typeof item.checked == 'undefined'){
      Vue.set(item, "checked", true);
     }else {
      item.checked = !item.checked;
     }
    }
    

    image.png

    地址列表

    image.png

    image.png

    image.png

    image.png

    new Vue({
     el: '.container',
     data: {
      addressList: []
     },
     mounted: function() {
      this.$nextTick(function(){
      });
     },
     methods: {
      getAddressList: function() {
       var _this = this;
       this.$http.get("data/address.json").then(function (response){
       var res = response.data;
       if(res.status == "0"){
         _this.addressList = res.result;
       }
      });
     }
     }
    });
    

    image.png

    image.png

    v-model v-text v-show v-if v-bind v-for v-on
    

    axios


    请点赞!因为你的鼓励是我写作的最大动力!

    官方微信公众号

    吹逼交流群:711613774

    吹逼交流群

  • 相关阅读:
    SHELL
    终端如何输出彩色字体
    BTree和B+Tree详解
    博客项目----小功能模块
    python的学习之旅---Mysql数据库
    Python的学习之旅———协程
    python的学习之旅---信号量 定时器
    python的学习之旅---回调机制
    Python的学习之旅———线程 事件
    centos安装redis
  • 原文地址:https://www.cnblogs.com/dashucoding/p/11140172.html
Copyright © 2020-2023  润新知