zoukankan      html  css  js  c++  java
  • Vue 计算属性

    计算属性适用于逻辑复杂时使用,依赖于其他值的变化而变化,当计算属性中的值不发生变化时该计算属性仍然是上一次变化后缓存下来的值。

    计算属性与监听器不同的是,监听器适用于当某个数据源发生变化时做其他某种操作,能够得到该数据源变化前后的值。

    计算属性方法:

    
    
    computed: {
    getInfo() {
    if (this.sitId!=""&& this.sitId!=undefined){
    this.loading = true;
    this.getData(sitId);
    }
    return sitId;
    },
      className(){
        return this.number1+this.number2
      } 
    },

    使用计算属性

     <div class="loginCms-top">
            <p>{{className}}</p>
            <button @click="getInfo"></button> 
      </div>    
  • 相关阅读:
    运算符
    格式化输出
    while循环
    if 判断语句
    Swift # 字典
    Swift # 数组
    Swift # 字符串
    [ Swift # 函数 ]
    [ Bubble Sort ]& block
    数据结构 # 二叉树/堆/栈
  • 原文地址:https://www.cnblogs.com/xibaomeng/p/13713697.html
Copyright © 2011-2022 走看看