Skip to content

Commit fc80f89

Browse files
committed
add reference for withModifiers()
1 parent 8bdf800 commit fc80f89

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

src/api/render-function.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Creates virtual DOM nodes (vnodes).
9393
})
9494
```
9595

96-
- See also: [Guide - Creating VNodes](/guide/extras/render-function.html#creating-vnodes)
96+
- **See also:** [Guide - Creating VNodes](/guide/extras/render-function.html#creating-vnodes)
9797

9898
## mergeProps()
9999

@@ -278,12 +278,16 @@ For adding custom directives to vnodes.
278278
- **Example**
279279

280280
```js
281-
import { h, withDirectives } from Vue
281+
import { h, withDirectives } from 'vue'
282282

283283
// a custom directive
284284
const pin = {
285-
mounted() { /* ... */ },
286-
updated() { /* ... */ }
285+
mounted() {
286+
/* ... */
287+
},
288+
updated() {
289+
/* ... */
290+
}
287291
}
288292

289293
// <div v-pin:top.animate="200"></div>
@@ -293,3 +297,28 @@ For adding custom directives to vnodes.
293297
```
294298
295299
- **See also:** [Guide - Render Functions - Custom Directives](/guide/extras/render-function.html#custom-directives)
300+
301+
## withModifiers()
302+
303+
For adding built-in [`v-on` modifiers](/guide/essentials/event-handling.html#event-modifiers) to an event handler function.
304+
305+
- **Type**
306+
307+
```ts
308+
function withModifiers(fn: Function, modifiers: string[]): Function
309+
```
310+
311+
- **Example**
312+
313+
```js
314+
import { h, withModifiers } from 'vue'
315+
316+
const vnode = h('button', {
317+
// equivalent of v-on.stop.prevent
318+
onClick: withModifiers(() => {
319+
// ...
320+
}, ['stop', 'prevent'])
321+
})
322+
```
323+
324+
- **See also:** [Guide - Render Functions - Event Modifiers](/guide/extras/render-function.html#event-modifiers)

src/guide/extras/render-function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ h('input', {
385385
/>
386386
```
387387

388-
For other event and key modifiers, the `withModifiers` helper can be used:
388+
For other event and key modifiers, the [`withModifiers`](/api/render-function.html#withmodifiers) helper can be used:
389389

390390
```js
391391
import { withModifiers } from 'vue'

0 commit comments

Comments
 (0)