What Is New in Vue.js 2.6
Vue 2.6 "Macchiato" delivers a significant syntax upgrade for slots and introduces several key improvements and fixes.
| Category | Key Changes |
|---|---|
| New Features | New slot syntax (v-slot directive), asynchronous error handling for v-on, dynamic directive arguments |
| Improvements | Performance optimizations for scoped slots, server-side rendering, and the compiler |
| Bug Fixes | Fixes for v-model, scoped slots, and functional components |
| Deprecations | Deprecation of the special $listeners property and slot="..." syntax |
What is the new v-slot syntax?
The new unified v-slot directive replaces the deprecated slot and slot-scope attributes. This provides a clearer and more consistent syntax for working with both default and scoped slots directly in the template.
In practice, this cleans up your template code significantly. Instead of mixing different attributes, you now use the v-slot directive on a <template> tag for all slot interactions.
Before (Deprecated)
<my-component>
<div slot="header">...</div>
<div slot-scope="{ data }">{{ data }}</div>
</my-component>
After (New Syntax)
<my-component>
<template v-slot:header>...</template>
<template v-slot:default="{ data }">{{ data }}</template>
</my-component>
How are asynchronous errors handled now?
Vue 2.6 introduces the ability to handle errors from asynchronous event handlers. You can now use v-on with a modifier to catch promise rejections from async functions.
This matters because it simplifies error handling for async operations within your component methods. You no longer need to wrap every async call in a try/catch block just to handle UI errors.
<button @click.prevent="asyncMethod" v-on:error.capture="handleError">
Submit
</button>
What performance improvements were made?
This release includes several under-the-hood optimizations that make your apps faster. The most notable improvements are in scoped slot rendering performance and server-side rendering efficiency.
Scoped slots now have a more efficient rendering mechanism. In our tests, we saw a measurable reduction in render time for complex component trees that make heavy use of scoped slots.
What about dynamic directive arguments?
Vue 2.6 allows you to use dynamic arguments for custom directives. This means you can now bind directive arguments dynamically using square bracket syntax, similar to how dynamic props work.
This opens up new patterns for creating flexible directives. You can now change directive behavior based on component state without having to re-create the directive.
<div v-mydirective:[dynamicArg]="value"></div>
FAQ
Is the old slot syntax completely broken now?
No, the old slot and slot-scope syntax still works but is now deprecated. You'll get warnings in development mode. The new v-slot syntax is the recommended approach for new code.
Do I need to rewrite all my existing slots immediately?
Not immediately. The deprecation is a warning, not an error. You can upgrade to 2.6 and migrate your slots gradually as you maintain different parts of your application.
Can I use the new async error handling with any method?
It works specifically with methods that return promises. If your async function rejects, the error handler will be triggered. Regular synchronous errors are not caught by this mechanism.
Are the performance improvements noticeable?
For most applications, the difference might be subtle. However, if you have complex components with many scoped slots or are doing heavy server-side rendering, you should see measurable improvements in rendering speed.
What happens if I use both old and new slot syntax?
Vue will use the new v-slot syntax if both are present on the same element. However, mixing syntax in the same project is allowed during the migration period.