Skip to content

Commit e788822

Browse files
committed
reorder note about v-on's object syntax
1 parent 829dec0 commit e788822

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/v2/api/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,21 +1869,18 @@ type: api
18691869

18701870
Attaches an event listener to the element. The event type is denoted by the argument. The expression can be a method name, an inline statement, or omitted if there are modifiers present.
18711871

1872-
Starting in 2.4.0+, `v-on` also supports binding to an object of event/listener pairs without an argument. Note when using the object syntax, it does not support any modifiers.
1873-
18741872
When used on a normal element, it listens to [**native DOM events**](https://developer.mozilla.org/en-US/docs/Web/Events) only. When used on a custom element component, it listens to **custom events** emitted on that child component.
18751873

18761874
When listening to native DOM events, the method receives the native event as the only argument. If using inline statement, the statement has access to the special `$event` property: `v-on:click="handle('ok', $event)"`.
18771875

1876+
Starting in 2.4.0+, `v-on` also supports binding to an object of event/listener pairs without an argument. Note when using the object syntax, it does not support any modifiers.
1877+
18781878
- **Example:**
18791879

18801880
```html
18811881
<!-- method handler -->
18821882
<button v-on:click="doThis"></button>
18831883
1884-
<!-- object syntax (2.4.0+) -->
1885-
<button v-on="{ mousedown: doThis, mouseup: doThat }"></button>
1886-
18871884
<!-- inline statement -->
18881885
<button v-on:click="doThat('hello', $event)"></button>
18891886
@@ -1910,6 +1907,9 @@ type: api
19101907
19111908
<!-- the click event will be triggered at most once -->
19121909
<button v-on:click.once="doThis"></button>
1910+
1911+
<!-- object syntax (2.4.0+) -->
1912+
<button v-on="{ mousedown: doThis, mouseup: doThat }"></button>
19131913
```
19141914

19151915
Listening to custom events on a child component (the handler is called when "my-event" is emitted on the child):

0 commit comments

Comments
 (0)