Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-bind shorthand for equal property and attribute name #8457

Closed
CyberAP opened this issue Jul 5, 2018 · 6 comments
Closed

v-bind shorthand for equal property and attribute name #8457

CyberAP opened this issue Jul 5, 2018 · 6 comments

Comments

@CyberAP
Copy link

CyberAP commented Jul 5, 2018

What problem does this feature solve?

Sometimes we're binding attributes to the props that have exactly the same name. So we could simplify v-bind:attr="attr" or :attr="attr" to just this: :attr.

What does the proposed API look like?

<Component :attr />

Equals to

<Component :attr="attr" />

Equals to

<Component v-bind:attr="attr" />
@JounQin
Copy link
Contributor

JounQin commented Jul 5, 2018

#2877 (comment)

@CyberAP
Copy link
Author

CyberAP commented Jul 5, 2018

Haven't found that in google results. Thanks.

@CyberAP CyberAP closed this as completed Jul 5, 2018
@leopiccionia
Copy link

With ES6 syntax, you can write:

<Component v-bind="{ foo, bar, baz}" />

That's equivalent to:

<Component :foo="foo" :bar="bar" :baz="baz" />

More details on Vue API docs.

@CyberAP
Copy link
Author

CyberAP commented Jul 5, 2018

@leopiccionia, thanks!

@Mouvedia
Copy link

@leopiccionia can you handle camelcase to kebabcase conversion automatically ?

@vis97c
Copy link

vis97c commented Jan 8, 2024

Vue 3.4 now supports this feature. See vuejs/core#9451 or the Announcement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants