Vue3 watch 监听对象数组中的特定值

    const rows = [{count:1,name:'a'}, {count:2,name:'b'}]
    watch(
      () => {
        return rows.map((item) => item.count);
      },
      (val) => {
        // 累加结果
        const sum = val.reduce((prev, curr) => prev + curr, 0)
      },
    );

你可能感兴趣的:(前端,vue.js,javascript)