Skip to content

Revise component-basics.md #740

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
Dec 18, 2020

Conversation

skirtles-code
Copy link
Contributor

@skirtles-code skirtles-code commented Dec 9, 2020

I've revised component-basics.md. In a few places there were descriptions of Vue 2 functionality that no longer apply with Vue 3. I've also tweaked grammar and wording in various places.

I've made inline comments for the most significant changes.

There are two things I've removed in multiple places:

  1. The word fortunately. The word itself is fine but it seems to be introducing core features as though their existence is a lucky coincidence.
  2. The expression keep in mind. There's an implication in that expression that a concept has been discussed previously. It can't really be used to introduce something new.

@@ -398,7 +396,7 @@ In the example above, `currentTabComponent` can contain either:

See [this sandbox](https://codepen.io/team/Vue/pen/oNXaoKy) to experiment with the full code, or [this version](https://codepen.io/team/Vue/pen/oNXapXM) for an example binding to a component's options object, instead of its registered name.

Keep in mind that this attribute can be used with regular HTML elements, however they will be treated as components, which means all attributes **will be bound as DOM attributes**. For some properties such as `value` to work as you would expect, you will need to bind them using the [`.prop` modifier](../api/directives.html#v-bind).
You can also use the `is` attribute to create regular HTML elements.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of this paragraph is no longer true in Vue 3, so I've removed it. The lone remaining sentence feels a bit out of place but it is an important point that I didn't want to lose.


That's all you need to know about registration for now, but once you've finished reading this page and feel comfortable with its content, we recommend coming back later to read the full guide on [Component Registration](component-registration.md).

## Passing Data to Child Components with Props

Earlier, we mentioned creating a component for blog posts. The problem is, that component won't be useful unless you can pass data to it, such as the title and content of the specific post we want to display. That's where props come in.

Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance. To pass a title to our blog post component, we can include it in the list of props this component accepts, using a `props` option:
Props are custom attributes you can register on a component. To pass a title to our blog post component, we can include it in the list of props this component accepts, using the `props` option:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Despite appearances, I haven't removed the middle sentence entirely, I've just moved it to after the example. The 5 sentences that appeared directly before and after this example are all still present but I've moved them around and reworded one of them. I think they form more natural paragraphs this way.

@@ -40,7 +40,7 @@ app.mount('#components-demo')

<common-codepen-snippet title="Component basics" slug="abORVEJ" tab="js,result" :preview="false" />

Since components are reusable instances, they accept the same options as a root instance, such as `data`, `computed`, `watch`, `methods`, and lifecycle hooks. The only exceptions are a few root-specific options like `el`.
Since components are reusable instances, they accept the same options as a root instance, such as `data`, `computed`, `watch`, `methods`, and lifecycle hooks.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe the final sentence is true in Vue 3 so I've removed it.

@skirtles-code skirtles-code marked this pull request as ready for review December 9, 2020 03:26
Copy link
Member

@NataliaTepluhina NataliaTepluhina left a comment

Choose a reason for hiding this comment

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

@skirtles-code awesome refactoring! I've added one non-blocking nitpick but the rest looks good to me 👍🏻

Copy link
Member

@NataliaTepluhina NataliaTepluhina left a comment

Choose a reason for hiding this comment

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

Happy to approve this one! I'll give this one more day to allow other maintainers taking a look but if there are no objections in the upcoming day, I'm going to merge it

@skirtles-code
Copy link
Contributor Author

Thanks. Always grateful for the scrutiny. I'd be happy to wait until next week if you want to let the weekend contributors have their opportunity.

@NataliaTepluhina
Copy link
Member

@skirtles-code seems there are no objections so let's merge it 🎉

@NataliaTepluhina NataliaTepluhina merged commit 0eebf0e into vuejs:master Dec 18, 2020
fimion pushed a commit to fimion/docs-next that referenced this pull request Dec 21, 2020
* docs: revise component-basics.md

* docs: reword a sentence to avoid repeating 'component instance'
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