Vue 3.5 is the latest release in the Vue.js framework and it comes with a number of exciting new features and improvements. In this tutorial, we will delve into the changes and enhancements that are included in the Vue 3.5 update.
- Teleport Component: The new Teleport component allows developers to render a child component at a different DOM location in the document. This can be useful for creating modals, popovers, context menus, and other components that need to be rendered outside the normal flow of the application.
<template>
<teleport to="body">
<modal :show="isOpen" @close="isOpen = false" />
</teleport>
</template>
- Composition API Enhancements: The Composition API has been enhanced to support the new
onUnmounted
lifecycle hook, which can be used to perform cleanup tasks when a component is unmounted from the DOM. This can be useful for cleaning up event listeners, timers, or other resources that may need to be cleaned up when a component is no longer needed.
import { onUnmounted } from 'vue'
setup() {
onUnmounted(() => {
// Cleanup tasks
})
}
- Improved TypeScript Support: Vue 3.5 includes improvements to TypeScript support, including better type inference and improved type checking. This can help developers catch more errors at compile time and write more robust and type-safe Vue applications.
const state = ref<number>(0)
-
Performance Improvements: Vue 3.5 includes various performance improvements, such as faster rendering times, reduced memory usage, and improved reactivity system performance. These enhancements can help make Vue applications faster and more responsive, especially for large and complex applications.
-
Easier SSR Setup: Server-side rendering (SSR) setup has been made easier in Vue 3.5, with simplified server-side hydration and improved support for async components in SSR. This can help developers build faster-loading and more SEO-friendly Vue applications.
- New Features in the Composition API: The Composition API has been enhanced with new features, such as
provide
andinject
for providing and injecting dependencies into components,watchEffect
for creating reactive side effects, andtoRefs
for converting reactive objects to refs. These new features can help developers write more flexible and modular Vue components.
export default {
setup() {
const { user } = inject('userStore')
watchEffect(() => {
console.log(user.name)
})
return { user }
}
}
Overall, Vue 3.5 brings a number of exciting new features and improvements that can help developers build faster, more robust, and more maintainable Vue applications. By taking advantage of these new features and enhancements, developers can create better user experiences and more efficient web applications using the Vue.js framework.
Thanks, this video solved an issue i was dealing with
Хорош 👍
Really lookfing forward to trying out this hydrateOnVisible feature!
Bye toRefs
Props destructuring and defaults looks 🔥
Please do not use dark theme for videos. Think about people which can't handle it.
Accessibility matters. Thank you.
Cool stuff, excited to put them in practice🎉
useTemplateRef…
Omg, the $ref() util which returns the component/element reference the proper way was the first thing ive written when migrated to v3😂
Yet again it is sad that Evan (or the core team) is not consecutive in their changes. $ is a standard for dom since jquery era, also v2 had a proper api which was $refs.
And instead of calling the api $ref() they named it in a weird way…
No logic found, as always.
Thanks for the recap