3👍
-
Don’t use
this
in<script setup>
-
Options API data can be accessed through getCurrentInstance but it’s not recommended (thanks @EstusFlask)
-
Don’t mix
Options API
withComposition API
, if it not really necessary.
Just choose one Vue API
and do all the code using it.
For Options API add
computed:
calculated() {
return this.name_.length > 0 ? 'Yes' : 'No'
}
For Composition API add
const name_ = ref("ertz")
const address_ = ref("aasf")
const phone_ = ref("100 xx 50")
const calculated = computed(() => {
return name_.length > 0 ? 'Yes' : 'No'
})
Source:stackexchange.com