Vue 3 is coming soon. If you have Vue 2 applications, now’s the time to prepare. Here’s how to get ready for the migration.
Breaking Changes to Address
- Filters removed: Replace with computed or methods
- $on, $off, $once removed: Use external event bus
- v-model changes: Multiple v-model support
- Functional components: Simpler syntax
Filters Migration
<!-- Vue 2 -->
{{ price | currency }}
<!-- Vue 3 - Use computed or method -->
{{ formatCurrency(price) }}
methods: {
formatCurrency(value) {
return new Intl.NumberFormat('en-US', {
style: 'currency', currency: 'USD'
}).format(value);
}
}
Event Bus Migration
// Vue 2 - Component-based bus
const bus = new Vue();
bus.$on('event', handler);
// Vue 3 - Use mitt or tiny-emitter
import mitt from 'mitt';
const emitter = mitt();
emitter.on('event', handler);
Preparation Steps
- Update to Vue 2.7 (backports some Vue 3 APIs)
- Remove deprecated patterns
- Add TypeScript types (optional but helpful)
- Use the official migration build when available
References
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.