-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Closed
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.✨ feature requestNew feature or requestNew feature or request
Description
Version
3.2.31
Reproduction link
Steps to reproduce
I know that refs or computed-s inside objects and arrays don't get unwrapped in the templates.
And that's exactly the issue with the code below:
<script setup>
import { computed, ref } from "vue";
const computedInsideArray = [computed(() => "text")];
const refInsideObject = { val: ref("text") };
</script>
<template>
<div>{{ computedInsideArray[0] }}</div> <!-- "text" >
<div>{{ refInsideObject.val }}</div> <!-- "text" >
</template>The solution is to just use .value
What is expected?
Since accessed element is an object which contains a .value property, an object should be rendered:
{ "value": "text" }What is actually happening?
"text" (with quotes) is rendered.
In many cases, it can be easy to forget or miss adding .value. And if that happens when a string is returned inside a computed or a ref inside an object or array, it might be difficult to debug since you are going to see the string you want, but inside quotes. And intuitively you might think this is a bug or an issue related to the quotes.
Metadata
Metadata
Assignees
Labels
🍰 p2-nice-to-havePriority 2: this is not breaking anything but nice to have it addressed.Priority 2: this is not breaking anything but nice to have it addressed.✨ feature requestNew feature or requestNew feature or request