📜  vue 3 计算的 getter setter - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:10.805000             🧑  作者: Mango

代码示例1
const count = ref(1)
const plusOne = computed({
  get: () => count.value + 1,
  set: val => {
    count.value = val - 1
  }
})

plusOne.value = 1
console.log(count.value) // 0
1