v-bind for style is confusing #13984
-
Hi, I saw the official doc for
It said the expression must be quoted. When I try in Vue, it also actually work without quotes. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
It refers to the following use case <script setup>
import { ref } from 'vue'
const theme = ref({
color: 'red',
})
</script>
<template>
<p>hello</p>
</template>
<style scoped>
p {
color: v-bind('theme.color');
}
</style> |
Beta Was this translation helpful? Give feedback.
@skirtles-code Thanks for the detailed information and reference. Your statements are defenitely making sense.
What I found in the source code for Vue compiling the style is here.
It seems the compiler will normalize the expression and it actually works with or without the quote for now.
Personally I think the doc need to be updated where the quote is actually optional insetad of
must be wrapped in quotes
as it's misleading according to the source code for what the compiler is doing.