Skip to content

Commit 9c98629

Browse files
feat: added explanation on prop modifiers
1 parent 0e5dda7 commit 9c98629

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

src/api/built-in-directives.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ Dynamically bind one or more attributes, or a component prop to an expression.
319319
<svg><a :xlink:special="foo"></a></svg>
320320
```
321321

322-
The `.prop` modifier also has a dedicated shorthand, `.`:
322+
The `.prop` modifier has a dedicated shorthand, `.`:
323323

324324
```vue-html
325325
<div :someProperty.prop="someObject"></div>
@@ -328,6 +328,15 @@ Dynamically bind one or more attributes, or a component prop to an expression.
328328
<div .someProperty="someObject"></div>
329329
```
330330

331+
The `.attr` modifier has a shorthand `^`:
332+
333+
```vue-html
334+
<div :someProperty.attr="someObject"></div>
335+
336+
<!-- equivalent to -->
337+
<div ^someProperty="someObject"></div>
338+
```
339+
331340
The `.camel` modifier allows camelizing a `v-bind` attribute name when using in-DOM templates, e.g. the SVG `viewBox` attribute:
332341

333342
```vue-html

src/guide/extras/render-function.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ h('div', { id: 'foo' })
3939
// Vue automatically picks the right way to assign it
4040
h('div', { class: 'bar', innerHTML: 'hello' })
4141

42+
// props modifiers such as .prop and .attr can be added via shorthands
43+
h('div', { .name: 'some-name', ^width: '100' })
44+
4245
// class and style have the same object / array
4346
// value support that they have in templates
4447
h('div', { class: [foo, { bar }], style: { color: 'red' } })
@@ -112,11 +115,7 @@ import { h } from 'vue'
112115
export default {
113116
setup() {
114117
// use an array to return multiple root nodes
115-
return () => [
116-
h('div'),
117-
h('div'),
118-
h('div')
119-
]
118+
return () => [h('div'), h('div'), h('div')]
120119
}
121120
}
122121
```
@@ -163,11 +162,7 @@ import { h } from 'vue'
163162
export default {
164163
render() {
165164
// use an array to return multiple root nodes
166-
return [
167-
h('div'),
168-
h('div'),
169-
h('div')
170-
]
165+
return [h('div'), h('div'), h('div')]
171166
}
172167
}
173168
```
@@ -563,8 +558,8 @@ Passing slots as functions allows them to be invoked lazily by the child compone
563558
import { h, KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
564559

565560
export default {
566-
setup () {
567-
return () => h(Transition, { mode: 'out-in' }, /* ... */)
561+
setup() {
562+
return () => h(Transition, { mode: 'out-in' } /* ... */)
568563
}
569564
}
570565
```
@@ -576,8 +571,8 @@ export default {
576571
import { h, KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
577572

578573
export default {
579-
render () {
580-
return h(Transition, { mode: 'out-in' }, /* ... */)
574+
render() {
575+
return h(Transition, { mode: 'out-in' } /* ... */)
581576
}
582577
}
583578
```
@@ -614,7 +609,8 @@ export default {
614609
render() {
615610
return h(SomeComponent, {
616611
modelValue: this.modelValue,
617-
'onUpdate:modelValue': (value) => this.$emit('update:modelValue', value)
612+
'onUpdate:modelValue': (value) =>
613+
this.$emit('update:modelValue', value)
618614
})
619615
}
620616
}
@@ -631,8 +627,12 @@ import { h, withDirectives } from 'vue'
631627

632628
// a custom directive
633629
const pin = {
634-
mounted() { /* ... */ },
635-
updated() { /* ... */ }
630+
mounted() {
631+
/* ... */
632+
},
633+
updated() {
634+
/* ... */
635+
}
636636
}
637637

638638
// <div v-pin:top.animate="200"></div>

0 commit comments

Comments
 (0)