vuejs-challenges
vuejs-challenges copied to clipboard
4 - 可写的计算属性
题目的意思应该是:plusOne 始终比count大1,plusOne可以改,如果改成100,那么count应该是99
<script setup lang="ts">
import { ref, computed } from "vue"
const count = ref(1)
const plusOne = computed({
get: () => count.value+1,
set: (val) =>{
count.value = val-1
return val
}
})
plusOne.value++
</script>