Skip to content

Update invoking-child-methods.md #42

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

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

skirtles-code
Copy link
Collaborator

This PR updates the answer to the question How do I call a method of a child component?.

The previous answer was a stub and has been completely replaced, though the core ideas remain the same.

- If you're using an explicit `setup` function, you'll need to return the method from `setup`, even if it isn't used in the child's own template. Anything returned from `setup` will be accessible via the template ref, unless you explicitly opt out by using the [`expose`](https://vuejs.org/api/options-state.html#expose) option.
- If the child is using the Options API, any method in the child's `methods` section will be accessible via the template ref, unless you're using the [`expose`](https://vuejs.org/api/options-state.html#expose) option to opt out.

## Debugging problems
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks for me as a good candidate for its own page

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it should really be moved to template-ref.md, which covers Why are my template refs not working?. I'll leave it here for now and move it when I finish off that page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually meant a more general page about debugging or at least debugging refs, not just template refs. It's a common problem that people are doing console.log(some ref/reactive/plain object) and wondering why it shows the data but ref.value.foo throws an error or shows different data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK, that'd be closer to logging-is-live.md, or at least it will be when I get round to writing it properly. It's not entirely clear to me yet how many pages we need for that topic.

@skirtles-code
Copy link
Collaborator Author

Based on the feedback I received, I've added two new sections to the end, Using props instead and Using v-model instead.

@skirtles-code skirtles-code merged commit b21b2de into vue-land:main Jan 24, 2025
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

Successfully merging this pull request may close these issues.

2 participants