Shorter binding for props with the same data name #405
Replies: 9 comments 9 replies
-
I really like the ideia. Svelte and React does this with brackets around the prop name: <blog-post
{title}
/> The proposed shorthand is very useful. So, to reduce the learning curve or refactoring, the new shorthand could be as close as the current <blog-post
:title
/> |
Beta Was this translation helpful? Give feedback.
-
I'll add my vote for
above it seemed obvious that I was binding the title variable to the title attribute. (I am relatively new to Vue, so my reaction is from someone who is not set in her ways and is already tired of typing |
Beta Was this translation helpful? Give feedback.
-
<blog-post
::author <!-- Instead of :author="author" -->
/> I love this. |
Beta Was this translation helpful? Give feedback.
-
I've just remembered single-colon shorthand was already proposed many times for Vue 2, and Evan wasn't a fan back then. See examples: Quoting one of them:
|
Beta Was this translation helpful? Give feedback.
-
Has this stalled? Another syntax idea: <blog-post
:{title}
/> |
Beta Was this translation helpful? Give feedback.
-
Since there was no RFC-Discussion open; I created an RFC regarding this issue. I proposed a solution which effectively supports this syntax: <blog-post
{title}
/> |
Beta Was this translation helpful? Give feedback.
-
I created a PR for <script setup lang="ts">
import { ref } from 'vue'
import Child from './child.vue'
const value = ref('')
</script>
<template>
<input :value /> <!-- <Child :value="value" /> -->
<Child ::value /> <!-- <Child v-model:value="value" /> -->
</template> |
Beta Was this translation helpful? Give feedback.
-
// how about
<comp @event></comp>
// equivalent to
<comp @event="event"></comp> |
Beta Was this translation helpful? Give feedback.
-
After I updated to this syntax I start to get eslint errors about unused variables
is there any way to properly fix it? |
Beta Was this translation helpful? Give feedback.
-
Hi guys!
I always thought that may be repetitive to re-write the prop value if it has the same name of the data we want to bind, so that's my suggestion: let us use another form of the
v-bind
shorthand for this purpose, for example:Let's suppose we have a prop called
title
and a data called the same way, what we usually do is this:As you can see, here we have a redundant information.
My purpose is to let us do this to achieve the same result:
Beta Was this translation helpful? Give feedback.
All reactions