Skip to content

Commit 47691ed

Browse files
authored
Update Introduction example to use components instead of .component() (#1296)
* Update Introduction example to use `components` instead of `.component()` * Replace SFC import with local component definition This fixes what was mentioned by the reviewer: #1296 (comment) * Remove unnecessary import comment
1 parent b9a6406 commit 47691ed

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/guide/introduction.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,16 @@ The component system is another important concept in Vue, because it's an abstra
223223
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:
224224

225225
```js
226-
// Create Vue application
227-
const app = Vue.createApp(...)
228-
229-
// Define a new component called todo-item
230-
app.component('todo-item', {
226+
const TodoItem = {
231227
template: `<li>This is a todo</li>`
228+
}
229+
230+
// Create Vue application
231+
const app = Vue.createApp({
232+
components: {
233+
TodoItem // Register a new component
234+
},
235+
... // Other properties for the component
232236
})
233237

234238
// Mount Vue application

0 commit comments

Comments
 (0)