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

Allow to v-bind the template ref #1681

Closed
ByScripts opened this issue Jul 22, 2020 · 2 comments
Closed

Allow to v-bind the template ref #1681

ByScripts opened this issue Jul 22, 2020 · 2 comments

Comments

@ByScripts
Copy link

What problem does this feature solve?

When using setup(), it would seems more natural to bind the ref property to the template ref attribute.

Bonus: Allows Ctrl/Cmd Click "Go to declaration" in IDE's :)

What does the proposed API look like?

<template>
  <h1 :ref="titleEl">Here is my title</h1>
</template>

<script>
export default {
  setup() {
    const titleEl = ref();
    return { titleEl };
  }
}
</script>
@ByScripts
Copy link
Author

ByScripts commented Jul 22, 2020

When using <h1 ref="titleEl">, it gives us the sensation of returning an unused property from setup().

@posva
Copy link
Member

posva commented Jul 22, 2020

This was discussed over at vuejs/rfcs#78 on the Template refs section. Having a string also allows dynamic refs.

@posva posva closed this as completed Jul 22, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants