Examining this code snippet, we see a string displayed that represents the content of a ref()
<script setup>
import { ref } from 'vue'
const msg = ref('x')
const asyncCall = () => {
const result = ref('one')
setTimeout(() => {
result.value = 'two'
}, 2000)
return result
}
msg.value = asyncCall()
</script>
<template>
<h1>{{ msg }}</h1>
</template>
What causes the quotation marks around the displayed value ("one"
and "two"
)?
Displayed below is an animated screenshot illustrating how "one"
transforms into "two"
when the window is reloaded.