From 91ffec6dc854db9c9628932056b5c622d8258528 Mon Sep 17 00:00:00 2001 From: Helios Date: Sat, 5 Sep 2020 11:00:56 +0800 Subject: [PATCH 1/2] add usage that pass setup function to defineComponent --- src/api/global-api.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/global-api.md b/src/api/global-api.md index f31af42c88..6dd87bd63a 100644 --- a/src/api/global-api.md +++ b/src/api/global-api.md @@ -130,6 +130,17 @@ const MyComponent = defineComponent({ }) ``` +Or a `setup` function, function name will be used as component name + +```js +import { defineComponent, ref } from 'vue' + +const HelloWorld = defineComponent(function HelloWorld() { + const count = ref(0) + return { count } +}) +``` + ## defineAsyncComponent Creates an async component that will be loaded only when it's necessary. From fc0c00d97e75428af337c84cc0919cd80421162e Mon Sep 17 00:00:00 2001 From: Helios Date: Sat, 26 Sep 2020 00:50:59 +0800 Subject: [PATCH 2/2] correct misleading content about render function --- src/guide/render-function.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/guide/render-function.md b/src/guide/render-function.md index 6fde9bf59d..8ae78f26ab 100644 --- a/src/guide/render-function.md +++ b/src/guide/render-function.md @@ -296,26 +296,16 @@ render() { #### Event Modifiers -For the `.passive`, `.capture`, and `.once` event modifiers, Vue offers object syntax of the handler: +For the `.passive`, `.capture`, and `.once` event modifiers, they can be concatenated after event name using camel case. For example: ```javascript render() { return Vue.h('input', { - onClick: { - handler: this.doThisInCapturingMode, - capture: true - }, - onKeyup: { - handler: this.doThisOnce, - once: true - }, - onMouseover: { - handler: this.doThisOnceInCapturingMode, - once: true, - capture: true - }, + onClickCapture: this.doThisInCapturingMode, + onKeyupOnce: this.doThisOnce, + onMouseoverOnceCapture: this.doThisOnceInCapturingMode, }) } ```