You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> In 2.2.0+, this hook also captures errors in component lifecycle hooks. Also, when this hook is `undefined`, captured errors will be logged with `console.error` instead of crashing the app.
84
84
85
-
> In 2.4.0+ this hook also captures errors thrown inside Vue custom event handlers.
85
+
> In 2.4.0+, this hook also captures errors thrown inside Vue custom event handlers.
86
+
87
+
> In 2.6.0+, this hook also captures errors thrown inside `v-on` DOM listeners. In addition, if any of the covered hooks or handlers returns a Promise chain (e.g. async functions), the error from that Promise chain will also be handled.
86
88
87
89
> Error tracking services [Sentry](https://sentry.io/for/vue/) and [Bugsnag](https://docs.bugsnag.com/platforms/browsers/vue/) provide official integrations using this option.
Make an object reactive. Internally, Vue uses this on the object returned by the `data` function.
417
+
418
+
The returned object can be used directly inside [render functions](../guide/render-function.html) and [computed properties](../guide/computed.html), and will trigger appropriate updates when mutated. It can also be used as a minimal, cross-component state store for simple scenarios:
419
+
420
+
```js
421
+
conststate=Vue.observable({ count:0 })
422
+
423
+
constDemo= {
424
+
render(h) {
425
+
returnh('button', {
426
+
on: { click: () => { state.count++ }}
427
+
}, `count is: ${state.count}`)
428
+
}
429
+
}
430
+
```
431
+
432
+
<pclass="tip">In Vue 2.x, `Vue.observable` directly mutates the object passed to it, so that it is equivalent to the object returned, as [demonstrated here](../guide/instance.html#Data-and-Methods). In Vue 3.x, a reactive proxy will be returned instead, leaving the original object non-reactive if mutated directly. Therefore, for future compatibility, we recommend always working with the object returned by `Vue.observable`, rather than the object originally passed to it.</p>
433
+
434
+
-**See also:**[Reactivity in Depth](../guide/reactivity.html)
435
+
405
436
### Vue.version
406
437
407
438
-**Details**: Provides the installed version of Vue as a string. This is especially useful for community plugins and components, where you might use different strategies for different versions.
Accessing `vm.$scopedSlots` is most useful when writing a component with a [render function](../guide/render-function.html).
1403
1434
1435
+
**Note:** since 2.6.0+, there are two notable changes to this property:
1436
+
1437
+
1. Scoped slot functions are now guaranteed to return an array of VNodes, unless the return value is invalid, in which case the function will return `undefined`.
1438
+
1439
+
2. All `$slots` are now also exposed on `$scopedSlots` as functions. If you work with render functions, it is now recommended to always access slots via `$scopedSlots`, whether they currently use a scope or not. This will not only make future refactors to add a scope simpler, but also ease your eventual migration to Vue 3, where all slots will be functions.
In 2.6+, `v-for` can also work on values that implement the [Iterable Protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol), including native `Map` and `Set`. However, it should be noted that Vue 2.x currently does not support reactivity on `Map` and `Set` values, so cannot automatically detect changes.
2017
+
1979
2018
<p class="tip">When used together with v-if, v-for has a higher priority than v-if. See the <a href="../guide/list.html#v-for-with-v-if">list rendering guide</a>for details.</p>
1980
2019
1981
2020
The detailed usage for`v-for` is explained in the guide section linked below.
<!-- shorthand dynamic attribute name (2.6.0+) -->
2152
+
<button :[key]="value"></button>
2153
+
2103
2154
<!-- with inline string concatenation -->
2104
2155
<img :src="'/path/to/images/' + fileName">
2105
2156
@@ -2164,6 +2215,59 @@ type: api
2164
2215
- [Form Input Bindings](../guide/forms.html)
2165
2216
- [Components - Form Input Components using Custom Events](../guide/components.html#Form-Input-Components-using-Custom-Events)
2166
2217
2218
+
### v-slot
2219
+
2220
+
-**Shorthand:**`#`
2221
+
2222
+
-**Expects:** JavaScript expression that is valid in a function argument position (supportsdestructuringin [supportedenvironments](../guide/components-slots.html#Slot-Props-Destructuring)). Optional - only needed if expecting props to be passed to the slot.
2223
+
2224
+
- **Argument:** slot name (optional, defaults to `default`)
2225
+
2226
+
- **Limited to:**
2227
+
- `<template>`
2228
+
- [components](../guide/components-slots.html#Abbreviated-Syntax-for-Lone-Default-Slots) (for a lone default slot with props)
2229
+
2230
+
- **Usage:**
2231
+
2232
+
Denote named slots or slots that expect to receive props.
2233
+
2234
+
- **Example:**
2235
+
2236
+
```html
2237
+
<!-- Named slots -->
2238
+
<base-layout>
2239
+
<template v-slot:header>
2240
+
Header content
2241
+
</template>
2242
+
2243
+
Default slot content
2244
+
2245
+
<template v-slot:footer>
2246
+
Footer content
2247
+
</template>
2248
+
</base-layout>
2249
+
2250
+
<!-- Named slot that receives props -->
2251
+
<infinite-scroll>
2252
+
<template v-slot:item="slotProps">
2253
+
<div class="item">
2254
+
{{ slotProps.item.text }}
2255
+
</div>
2256
+
</template>
2257
+
</infinite-scroll>
2258
+
2259
+
<!-- Default slot that receive props, with destructuring -->
Used to denote an element or component as a scoped slot. The attribute's value should be a valid JavaScript expression that can appear in the argument position of a function signature. This means in supported environments you can also use ES2015 destructuring in the expression. Serves as a replacement for [`scope`](#scope-replaced) in 2.5.0+.
Used to denote an element or component as a scoped slot. The attribute's value should be a valid JavaScript expression that can appear in the argument position of a function signature. This means in supported environments you can also use ES2015 destructuring in the expression. Serves as a replacement for [`scope`](#scope-replaced) in 2.5.0+.
2434
+
2435
+
This attribute does not support dynamic binding.
2436
+
2437
+
- **See also:** [Scoped Slots with `slot-scope`](../guide/components.html#Scoped-Slots-with-slot-scope)
0 commit comments