Skip to content

Instantly share code, notes, and snippets.

@guillaumeduhan
Created June 17, 2021 17:07
Show Gist options
  • Save guillaumeduhan/39f7ca4282e2235e61f4e07ffee26239 to your computer and use it in GitHub Desktop.
Save guillaumeduhan/39f7ca4282e2235e61f4e07ffee26239 to your computer and use it in GitHub Desktop.
Vue 3: computed
<template>
<div>
<input v-model.lazy="name" />
<p>{{ msg }}</p>
</div>
</template>
<script>
import { reactive, toRefs, computed } from "vue";
export default {
setup () {
const data = reactive({
name: 'Guillaume',
msg: computed(() => {
return `Hello ${data.name}`
})
})
return {
...toRefs(data)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment