Skip to content

Commit dfd86d3

Browse files
authored
Fix grammatical errors and introduce app.component() in introduction.md (#1388)
* Fixed grammatical error in theme-data.js In the Flatlogic description, the phrase "how real applications is built" is grammatically incorrect since "applications" is a plural noun but "is" refers to a singular noun. I changed it to "how real applications are built." In the PrimeVue description, the phrase "look&feel" (which lacked spaces between the words and punctuation) has been changed to "look & feel". * Update theme-data.js In the Flatlogic description, "Check the admin dashboard templates" has been changed to "Check out the admin dashboard templates." * Fix grammar and introduce the component method * Add missing 'a' * Update introduction to include reviewer's changes Removed all use of the app.component() method from the introduction so as to not confuse readers.
1 parent d47173d commit dfd86d3

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/guide/introduction.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const Counter = {
5252
Vue.createApp(Counter).mount('#counter')
5353
```
5454

55-
We have already created our very first Vue app! This looks pretty similar to rendering a string template, but Vue has done a lot of work under the hood. The data and the DOM are now linked, and everything is now **reactive**. How do we know? Take a look at the example below where `counter` property increments every second and you will see how rendered DOM changes:
55+
We have already created our very first Vue app! This looks pretty similar to rendering a string template, but Vue has done a lot of work under the hood. The data and the DOM are now linked, and everything is now **reactive**. How do we know? Take a look at the example below where the `counter` property increments every second and you will see how the rendered DOM changes:
5656

5757
```js{8-10}
5858
const Counter = {
@@ -158,7 +158,7 @@ Vue.createApp(TwoWayBinding).mount('#two-way-binding')
158158

159159
## Conditionals and Loops
160160

161-
It's easy to toggle the presence of an element, too:
161+
It's easy to toggle the presence of an element too:
162162

163163
```html
164164
<div id="conditional-rendering">
@@ -220,7 +220,7 @@ The component system is another important concept in Vue, because it's an abstra
220220

221221
![Component Tree](/images/components.png)
222222

223-
In Vue, a component is essentially an instance with pre-defined options. Registering a component in Vue is straightforward: we create a component object as we did with `App` objects and we define it in parent's `components` option:
223+
In Vue, a component is essentially an instance with pre-defined options. Registering a component in Vue is straightforward: we create a component object as we did with the `app` object and we define it in the parent's `components` option:
224224

225225
```js
226226
const TodoItem = {
@@ -251,10 +251,10 @@ Now you can compose it in another component's template:
251251
But this would render the same text for every todo, which is not super interesting. We should be able to pass data from the parent scope into child components. Let's modify the component definition to make it accept a [prop](component-basics.html#passing-data-to-child-components-with-props):
252252

253253
```js
254-
app.component('todo-item', {
254+
const TodoItem = {
255255
props: ['todo'],
256256
template: `<li>{{ todo.text }}</li>`
257-
})
257+
}
258258
```
259259

260260
Now we can pass the todo into each repeated component using `v-bind`:
@@ -278,6 +278,11 @@ Now we can pass the todo into each repeated component using `v-bind`:
278278
```
279279

280280
```js
281+
const TodoItem = {
282+
props: ['todo'],
283+
template: `<li>{{ todo.text }}</li>`
284+
}
285+
281286
const TodoList = {
282287
data() {
283288
return {
@@ -287,22 +292,20 @@ const TodoList = {
287292
{ id: 2, text: 'Whatever else humans are supposed to eat' }
288293
]
289294
}
295+
},
296+
components: {
297+
TodoItem
290298
}
291299
}
292300

293301
const app = Vue.createApp(TodoList)
294302

295-
app.component('todo-item', {
296-
props: ['todo'],
297-
template: `<li>{{ todo.text }}</li>`
298-
})
299-
300303
app.mount('#todo-list-app')
301304
```
302305

303306
<common-codepen-snippet title="Intro-Components-1" slug="VwLxeEz" />
304307

305-
This is a contrived example, but we have managed to separate our app into two smaller units, and the child is reasonably well-decoupled from the parent via the props interface. We can now further improve our `<todo-item>` component with more complex template and logic without affecting the parent app.
308+
This is a contrived example, but we have managed to separate our app into two smaller units, and the child is reasonably well-decoupled from the parent via the props interface. We can now further improve our `<todo-item>` component with a more complex template and logic without affecting the parent app.
306309

307310
In a large application, it is necessary to divide the whole app into components to make development manageable. We will talk a lot more about components [later in the guide](component-basics.html), but here's an (imaginary) example of what an app's template might look like with components:
308311

0 commit comments

Comments
 (0)