theme | title | download | monaco | highlighter | routerMode | colorSchema | info |
---|---|---|---|---|---|---|---|
default |
Introduction new feature in Vue 3 |
true |
false |
Prism |
hash |
dark |
## Introduction new feature in Vue 3
By Lucky Dewa Satria.
|
*Last Updated 30 May 2021
*Last Updated 30 May 2021
https://2018.stateofjs.com/front-end-frameworks/vuejs/
https://2018.stateofjs.com/front-end-frameworks/react/
https://www.monterail.com/state-of-vue-2021-report/
https://www.monterail.com/state-of-vue-2021-report/
- Lightweight (20KB min+gzip)
- Performant
new Vue({
data: {
message: 'Hello World!',
count: 0,
},
computed: {
fullname() {
/* ... */
},
},
methods: {
increment() {
this.count++;
},
},
});
smaller + faster
new features
exposes lower level APIs
improved TypeScript supoort
more maintainable codebase
- setting a new array item
- adding a new object
- deleting an object property
// Vue 2
Vue.set(this.users, index, 'Antonio');
// Vue 3
this.users[index] = 'Antonio';
// Vue 2
Vue.set(this.user, age, 32);
// Vue 3
this.user.age = 32;
// Vue 2
Vue.delete(this.user, age, 32);
// Vue 3
delete this.user.age;
<template>
<div>
<router-view>
<div id="teleport-target"></div>
<div>
</template>
<template>
<div>
<button @click="isRendered = !isRendered">
Render content
</button>
<Teleport to="#teleport-target">
<div>Hello World!</div>
</Teleport>
<div>
</template>
modals, notifications, and popups
layout content like withinsidebar, menu, and footer
<template>
<div>
<div>Hello</div>
<div>World!</div>
<div>
</template>
Vue 2
<template>
<div>Hello</div>
<div>World!</div>
</template>
Vue 3
<template>
<CustomForm v-model="name" />
</template>
Vue 2
<template>
<CustomForm v-model:name="name" v-model:email="email" />
</template>
Vue 3
Advanced Feature
Addition to the current API
Options API is not being deprecated
Code organiztion
Logic Reuse
Extremly Flexible
Clear source of properties
Performance
No namespace collision
component code grows too long
team that work on the same (big) components
reuse component options without using mixins
When TypeScript support is important
(own opinion)
(own opinion)
Overhead of introducing refs
learning curve
No need to rewrite yout vue 2 app
No need to use it in a simple component
(own opinion)
Renders some fallback content instead of a component until a condition is met
<Suspense>
<template #default>
<UserProfile />
</template>
<template>
<div>Loading...</div>
</template>
</Suspense>
Filters
<template>
<div>{{ amount | dollars }}</div>
</template>
<template>
<div>{{ dollars(amount) }}</div>
</template>
No more dilemas
Quite some more changes
Fragments
Emits Component Option
create custom renderers
Global mounting API change
...
Vue 3 will not break your apps
Massive performance improvements
Exceptional reusability possibilities
New Features
New design patterns for scale
TypeScript
Tech Stack