Skip to content

Migration > Props Data の翻訳を追従 #256

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 4 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const sidebar = {
'/guide/migration/keycode-modifiers',
'/guide/migration/listeners-removed',
'/guide/migration/mount-changes',
// '/guide/migration/props-data',
'/guide/migration/props-data',
'/guide/migration/props-default-this',
'/guide/migration/render-function-api',
'/guide/migration/slots-unification',
Expand Down
41 changes: 41 additions & 0 deletions src/guide/migration/props-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
badges:
- removed
---

# `propsData` <MigrationBadges :badges="$frontmatter.badges" />

## 概要

Vue インスタンスの生成時に props を渡すために使われていた `propsData` オプションは削除されました。Vue 3 アプリケーションのルートコンポーネントに props を渡すには、 [createApp](/api/global-api.html#createapp) の第2引数を使います。

## 2.x での構文

2.x では、 Vue インスタンスの生成時に props を渡すことができました:

```js
const Comp = Vue.extend({
props: ['username'],
template: '<div>{{ username }}</div>'
})

new Comp({
propsData: {
username: 'Evan'
}
})
```

## 3.x での更新

`propsData` オプションは削除されました。生成時にルートコンポーネントのインスタンスに props を渡す必要がある場合は、 `createApp` の第2引数を使ってください:

```js
const app = createApp(
{
props: ['username'],
template: '<div>{{ username }}</div>'
},
{ username: 'Evan' }
)
```