博客
关于我
vue计算属性和监听器区别
阅读量:370 次
发布时间:2019-03-05

本文共 2261 字,大约阅读时间需要 7 分钟。

?????????????????

?Vue.js?????????????????????????????????????????????????????????????????????

??????????????

?????Computed Property???????Watcher??Vue.js??????????

  • ????

    • ???????????????????????????????????????
    • ??????????computed?????????{}??????????methods????????????????????????
    • ?????????????????????????????????????????????
  • ????

    -??????????????????????????????????????? -???????????????????????????????????????????

  • ??????????????

    ?Element UI???????????????????????????????????????????????????????????

    ????
    watch: {
    total() {
    if (this.total === (this.currentPage - 1) * this.pageSize && this.total !== 0) {
    this.currentPage -= 1;
    getDiscountList(this); // ??????
    }
    }
    }

    ??????????????

    ??????????????????????????????????????

    computed: {
    limitData() {
    let data = [...this.table1Datas];
    return data;
    },
    dataWithPage() {
    const data = this.limitData;
    const start = this.current * this.size - this.size;
    const end = start + this.size;
    return [...data].slice(start, end);
    }
    },

    ????????????????

    ??????????????????????????????????

    ?????????????
    data() {
    return {
    // ??????...
    data: {
    pensionBase: '', // ?????
    pensionPer: '0.08', // ?????
    // ????????...
    }
    };
    },
    computed: {
    newPensionBase() {
    return this.data.pensionPer * this.data.basicSalary;
    },
    // ??????????...
    },
    watch: {
    // ?????????...
    },
    ?????????
    computed: {
    newaccumulationFundPer() {
    let basicSalary = this.data.basicSalary;
    if (basicSalary != null) {
    switch (true) {
    case basicSalary < 5000:
    return 0;
    case basicSalary >= 5000 && basicSalary < 80000:
    return 0.03;
    case basicSalary >= 8000 && basicSalary <= 17000:
    return 0.1;
    case basicSalary > 17000 && basicSalary <= 30000:
    return 0.2;
    case basicSalary > 30000 && basicSalary <= 40000:
    return 0.25;
    case basicSalary > 40000 && basicSalary <= 60000:
    return 0.3;
    default:
    return 0.45;
    }
    }
    return 0;
    }
    },

    ??????

    ?????????????????????????????????????????????????????????????????????????????

    ????

    ??????????Vue.js???????????????????????????????????????????????????????????????????????????????????

    转载地址:http://zlcg.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现十进制转八进制算法(附完整源码)
    查看>>
    Objective-C实现华氏温度转摄氏温度(附完整源码)
    查看>>
    Objective-C实现单例模式(附完整源码)
    查看>>
    Objective-C实现单向链表的反转(附完整源码)
    查看>>
    Objective-C实现单向链表的反转(附完整源码)
    查看>>
    Objective-C实现单字母密码算法(附完整源码)
    查看>>
    Objective-C实现单循环链表算法(附完整源码)
    查看>>
    Objective-C实现单词计数(附完整源码)
    查看>>
    Objective-C实现单链表反转(附完整源码)
    查看>>
    Objective-C实现博福特密码算法(附完整源码)
    查看>>
    Objective-C实现卡尔曼滤波(附完整源码)
    查看>>
    Objective-C实现卡尔曼滤波(附完整源码)
    查看>>
    Objective-C实现卡尔曼滤波(附完整源码)
    查看>>
    Objective-C实现卷积(附完整源码)
    查看>>
    Objective-C实现压缩文件夹(附完整源码)
    查看>>
    Objective-C实现原型模式(附完整源码)
    查看>>
    Objective-C实现双向A*算法(附完整源码)
    查看>>
    Objective-C实现双向广度优先搜索算法(附完整源码)
    查看>>
    Objective-C实现双向循环链表(附完整源码)
    查看>>
    Objective-C实现双向链表(附完整源码)
    查看>>