VUE-computed

vue:computed

當其依賴的屬性的值發生變化時,計算屬性會重新計算,反之,則使用緩存中的屬性值。
當computed中定義的屬性或者方法:包含或者依賴的值出現了變化,則會重新調用此方法或者計算此屬性。

  computed: {
    // 模糊搜索
    tables() {
      const  = this.a;
      if (a) {
        return a;
        });
      }
      return this.b;
    }
  }

比如:this.a變化時,會重新啓動tables函數。如果a有值,則返回a,否則返回b。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章