zoukankan      html  css  js  c++  java
  • (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

    吹逼交流群

  • 相关阅读:
    django-restframework使用
    django-xadmin使用
    python2.7.5升级到2.7.14或者直接升级到3.6.4
    mysql-5.7.25安装以及使用
    django1.9安装以及使用
    Algorithm negotiation failed
    ELK的搭建以及使用
    python 3.5 成功安装 scrapy 的步骤
    pandas基础-Python3
    C#命名规则和编码规范
  • 原文地址:https://www.cnblogs.com/dashucoding/p/11140172.html
Copyright © 2011-2022 走看看