在vue的计算属性中,所定义的都是属性,可以直接调用

正常情况下,计算属性中的每一个属性对应的都是一个对象,对象中包括了set方法与get方法

computed:{
    fullNname:{
        set:function(newValue){
            console.log(newValue)
        }
        get:function(){
            console.log(this.name)
        }
    }
}

而绝大多数情况下,计算属性没有set方法,是一个只读属性

此时计算属性可以简写

computed:{
    fullName:function(){
        console.log(this.name)
    }
}

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-01-29
  • 2022-02-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案