vue计算属性和监听器区别
发布日期:2021-05-08 00:22:17 浏览次数:19 分类:精选文章

本文共 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???????????????????????????????????????????????????????????????????????????????????

    上一篇:vue分页功能
    下一篇:删除页面最后一条数据时,currentPage没有减一,页面列表为空

    发表评论

    最新留言

    关注你微信了!
    [***.104.42.241]2025年04月30日 21时37分48秒