From 04f80cbc7165113c847efd449d93529b832a3979 Mon Sep 17 00:00:00 2001 From: Thorsten Luenborg Date: Wed, 7 Oct 2020 08:43:24 +0200 Subject: [PATCH 01/20] feat: Add migration guide for 3 changes: - $listeners removed - v-on.native modifier removed - new emits option --- src/.vuepress/config.js | 3 + src/guide/migration/emits-option.md | 61 +++++++++++++++ src/guide/migration/introduction.md | 9 ++- src/guide/migration/listeners-removed.md | 76 +++++++++++++++++++ .../migration/v-on-native-modifier-removed.md | 66 ++++++++++++++++ 5 files changed, 212 insertions(+), 3 deletions(-) create mode 100644 src/guide/migration/emits-option.md create mode 100644 src/guide/migration/listeners-removed.md create mode 100644 src/guide/migration/v-on-native-modifier-removed.md diff --git a/src/.vuepress/config.js b/src/.vuepress/config.js index 1e1b5e88b0..1057a3a012 100644 --- a/src/.vuepress/config.js +++ b/src/.vuepress/config.js @@ -123,6 +123,7 @@ const sidebar = { '/guide/migration/custom-directives', '/guide/migration/custom-elements-interop', '/guide/migration/data-option', + '/guide/migration/emits-option', '/guide/migration/events-api', '/guide/migration/filters', '/guide/migration/fragments', @@ -132,10 +133,12 @@ const sidebar = { '/guide/migration/inline-template-attribute', '/guide/migration/key-attribute', '/guide/migration/keycode-modifiers', + '/guide/migration/listeners-removed', '/guide/migration/props-default-this', '/guide/migration/render-function-api', '/guide/migration/slots-unification', '/guide/migration/transition', + '/guide/migration/v-on-native-modifier-removed', '/guide/migration/v-model', '/guide/migration/v-if-v-for', '/guide/migration/v-bind' diff --git a/src/guide/migration/emits-option.md b/src/guide/migration/emits-option.md new file mode 100644 index 0000000000..17f2e96da7 --- /dev/null +++ b/src/guide/migration/emits-option.md @@ -0,0 +1,61 @@ +--- +title: \`emits\` option +badges: + - new +--- + +# `emits` Option + +## Overview + +Vue 3 now offers an `emits` option similar to the existing `props` option. This option can be used to define the events that a component can emit to its parent. + +## 2.x Syntax + +In Vue 2, you can define the props that a component received, but you can't define which ebents it can emit: + +```javascript + + +``` + +## 3.x Syntax + +Similar to props, the events that the component emit can now be defined with the `emits` option. + +```javascript + + +``` + +The option also excepts an object notation, which allows to define validators for the arguments that have passed with the emitted event, similar to validators in props definitions. + +For more Information on this, please read the [API documentation for this feature](../api/options-data.md#emits). + +## Migration Strategy + +Even though this is the new optional feature, it is highly recommended that you document all of the emitted events of your components this way because of the [removal of the `.native` modifier](./native-modifier-removed.md). + +All events not defined with `emits` are now added as DOM event listeners to the components root node (unless `inheritAttrs: false` has been set). + +## See also + +- [Relevant RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0030-emits-option.md) +- [Migration guide - `$listeners` removed](/.listeners-removed.md) +- [Migration guide - `.native` modifier removed](./native-modifier-removed.md) +- [Migration guide - Changes in the Render Functions API](./render-functions.md) diff --git a/src/guide/migration/introduction.md b/src/guide/migration/introduction.md index 74cd2eca07..69b8bad32f 100644 --- a/src/guide/migration/introduction.md +++ b/src/guide/migration/introduction.md @@ -1,10 +1,10 @@ # Introduction -::: info -New to Vue.js? Check out our [Essentials Guide](/guide/introduction.html) to get started. +::: info +New to Vue.js? Check out our [Essentials Guide](/guide/introduction.html) to get started. ::: -This guide is primarily for users with prior Vue 2 experience who want to learn about the new features and changes in Vue 3. **This is not something you have to read from top to bottom before trying out Vue 3.** While it looks like a lot has changed, a lot of what you know and love about Vue is still the same; but we wanted to be as thorough as possible and provide detailed explanations and examples for every documented change. +This guide is primarily for users with prior Vue 2 experience who want to learn about the new features and changes in Vue 3. **This is not something you have to read from top to bottom before trying out Vue 3.** While it looks like a lot has changed, a lot of what you know and love about Vue is still the same; but we wanted to be as thorough as possible and provide detailed explanations and examples for every documented change. - [Quickstart](#quickstart) - [Notable New Features](#notable-new-features) @@ -69,6 +69,7 @@ The following consists a list of breaking changes from 2.x: - [`key` usage on `