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

Don't create refs link without modifier #7959

Closed
Drive4ik opened this issue Apr 3, 2018 · 2 comments
Closed

Don't create refs link without modifier #7959

Drive4ik opened this issue Apr 3, 2018 · 2 comments

Comments

@Drive4ik
Copy link

Drive4ik commented Apr 3, 2018

Version

2.5.16

Reproduction link

https://jsfiddle.net/vrLubr46/5/

Steps to reproduce

TypeError: "$refs.test is undefined"

If you add modifier (.prevent .stop etc.) to @click error will gone

What is expected?

Need work without any modifiers

What is actually happening?

javascript error occurs

@sirlancelot
Copy link

The issue is that during the initial render, $refs isn't populated. Overall though, I'd say that code is probably not good. $refs shouldn't be used inside templates, it's an escape hatch to be used in code.

You can avoid the bug by adding a method to your component which then calls the linked component like so: https://jsfiddle.net/vrLubr46/13/

@posva
Copy link
Member

posva commented Apr 4, 2018

Use a method or an inline function instead: @click="() => $refs.test.open"
Closing as there is already #3842

@posva posva closed this as completed Apr 4, 2018
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

3 participants