Computed inside reactive #11729
Answered
by
s3xysteak
erwinheldy
asked this question in
Help/Questions
-
Is it ok to write code like this ?: <script setup lang="ts">
import { computed, reactive } from 'vue'
const counter = reactive({
count: 0,
doubled: 0,
increment: () => counter.count++,
})
counter.doubled = computed(() => counter.count * 2) as any
</script>
<template>
<button @click="counter.increment">{{ counter.count }} * 2 = {{ counter.doubled }}</button>
</template> It works, but are there any performance issues? |
Beta Was this translation helpful? Give feedback.
Answered by
s3xysteak
Aug 29, 2024
Replies: 1 comment
-
It is ok but why not : const counter = reactive({
count: 0,
doubled: computed(() => counter.count * 2),
increment: () => counter.count++,
}) Less any less bug 😄 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
erwinheldy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is ok but why not :
Less any less bug 😄