Skip to content

Commit a239881

Browse files
LSViananaokie
authored andcommitted
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: vuejs/docs#1296 (comment) * Remove unnecessary import comment
1 parent 6f3f322 commit a239881

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/guide/introduction.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,19 @@ Vue.createApp(ListRendering).mount('#list-rendering')
223223
Vue において、コンポーネントは本質的にはあらかじめ定義されたオプションを持つインスタンスです。Vue を使ってコンポーネントを登録するのはいたって簡単で、`App` オブジェクトと同様にコンポーネントオブジェクトを作成し、親の `components` オプションで定義します:
224224

225225
```js
226-
// Vue アプリケーションを生成する
227-
const app = Vue.createApp(...)
228-
229-
// todo-item という名前の新しいコンポーネントを定義する
230-
app.component('todo-item', {
226+
const TodoItem = {
231227
template: `<li>This is a todo</li>`
228+
}
229+
230+
// Vue アプリケーションを生成する
231+
const app = Vue.createApp({
232+
components: {
233+
TodoItem // 新しいコンポーネントを登録する
234+
},
235+
... // その他のコンポーネントのプロパティ
232236
})
233237

234-
// Vue application をマウントする
238+
// Vue アプリケーションをマウントする
235239
app.mount(...)
236240
```
237241

0 commit comments

Comments
 (0)