VUE2.0中监听对象属性的方法

data() {
    return {
      addMealList: {
        name: "",
        price: "0",
        discount: "0",
        weight: "0",
      },
    };
  },
  watch: {
    addMealList: {
      handler: function(newVal) {
        console.log(newVal.price);
      },
      deep: true //深度监听
    }
  },

猜你喜欢

转载自blog.csdn.net/jiangwei1994/article/details/82496193