Skip to content

Added propsData to migration guide #916

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 7 commits into from
Mar 2, 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
1 change: 1 addition & 0 deletions src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const sidebar = {
'/guide/migration/key-attribute',
'/guide/migration/keycode-modifiers',
'/guide/migration/listeners-removed',
'/guide/migration/props-data',
'/guide/migration/props-default-this',
'/guide/migration/render-function-api',
'/guide/migration/slots-unification',
Expand Down
3 changes: 2 additions & 1 deletion src/guide/migration/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ The following consists a list of breaking changes from 2.x:
- [$on, $off and $once instance methods](/guide/migration/events-api.html)
- [Filters](/guide/migration/filters.html)
- [Inline templates attributes](/guide/migration/inline-template-attribute.html)
- [`$children` instance property](/guide/migration/children.md)
- [`$children` instance property](/guide/migration/children.html)
- [`propsData` option](/guide/migration/props-data.html)
- `$destroy` instance method. Users should no longer manually manage the lifecycle of individual Vue components.

## Supporting Libraries
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" />

## Overview

The `propsData` option, used to pass props to the Vue instance during its creation, is removed. To pass props to the root component of a Vue 3 application, use the second argument of [createApp](/api/global-api.html#createapp).

## 2.x Syntax

In 2.x, we were able to pass props to a Vue instance during its creation:

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

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

## 3.x Update

The `propsData` option has been removed. If you need to pass props to the root component instance during its creation, you should use the second argument of `createApp`:

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