### Configure Async Component Loader Source: https://v3-migration.vuejs.org/breaking-changes/async-components Example of the updated configuration object using the loader property. ```javascript import { defineAsyncComponent } from 'vue' const asyncModalWithOptions = defineAsyncComponent({ loader: () => import('./Modal.vue'), delay: 200, timeout: 3000, errorComponent: ErrorComponent, loadingComponent: LoadingComponent }) ``` -------------------------------- ### Vue 2 $attrs Example Source: https://v3-migration.vuejs.org/breaking-changes/listeners-removed An example of how attributes and listeners might be structured in Vue 2. ```js { text: 'this is an attribute', onClose: () => console.log('close Event triggered') } ``` -------------------------------- ### Install Plugins with app.use() Source: https://v3-migration.vuejs.org/breaking-changes/global-api Vue 2's global Vue.use() is replaced by the app instance's use() method in Vue 3. Plugins must now be explicitly installed on the app instance. ```javascript var inBrowser = typeof window !== 'undefined' /* … */ if (inBrowser && window.Vue) { window.Vue.use(VueRouter) } ``` ```javascript const app = createApp(MyApp) app.use(VueRouter) ``` -------------------------------- ### Vue 3 $attrs Example Source: https://v3-migration.vuejs.org/breaking-changes/listeners-removed An example of how attributes and listeners are structured in $attrs in Vue 3. ```js { id: 'my-input', onClose: () => console.log('close Event triggered') } ``` -------------------------------- ### Create App Instance in Vue 3 Source: https://v3-migration.vuejs.org/breaking-changes/global-api Basic example of creating a Vue 3 application instance using `createApp`. ```js import { createApp } from 'vue' const app = createApp({}) ``` -------------------------------- ### Attribute Binding Expressions Source: https://v3-migration.vuejs.org/breaking-changes/attribute-coercion Examples of v-bind expressions and their resulting HTML output for normal and enumerated attributes. ```html :attr="null" ``` ```html :attr="undefined" ``` ```html :attr="true" ``` ```html :attr="false" ``` ```html :attr="0" ``` ```html attr="" ``` ```html attr="foo" ``` ```html attr ``` -------------------------------- ### Register Global Component in Vue 2 Source: https://v3-migration.vuejs.org/breaking-changes/global-api Example of registering a global component using `Vue.component` in Vue 2. ```js Vue.component('button-counter', { data: () => ({ count: 0 }), template: '' }) ``` -------------------------------- ### Parent listening for component events Source: https://v3-migration.vuejs.org/breaking-changes/emits-option Example of a parent component listening for a click event on a child component. ```html ``` -------------------------------- ### Vue 3 Root Component Event Listener Setup Source: https://v3-migration.vuejs.org/breaking-changes/events-api In Vue 3, root component events can be listened to by passing them as props to `createApp`. This example shows how to listen for an 'expand' event. ```javascript createApp(App, { // Listen for the 'expand' event onExpand() { console.log('expand') } }) ``` -------------------------------- ### Create App Instance from CDN Build Source: https://v3-migration.vuejs.org/breaking-changes/global-api Example of creating a Vue 3 application instance when using a CDN build, accessing `createApp` from the global `Vue` object. ```js const { createApp } = Vue const app = createApp({}) ``` -------------------------------- ### Vue 2 Event Bus Implementation Source: https://v3-migration.vuejs.org/breaking-changes/events-api In Vue 2, a Vue instance could be used to create an event bus for global event listeners. This example shows the basic setup for an event bus. ```javascript const eventBus = new Vue() export default eventBus ``` -------------------------------- ### Vue 2 transition-group syntax Source: https://v3-migration.vuejs.org/breaking-changes/transition-group Example of using the tag attribute to define a root element in Vue 2. ```html
  • {{ item }}
  • ``` -------------------------------- ### Vue 2 Filter Syntax Example Source: https://v3-migration.vuejs.org/breaking-changes/filters In Vue 2, filters were used for text formatting within templates. This example shows a currency filter applied to a balance. ```html ``` -------------------------------- ### Vue 2.x Conditional Rendering with Keys Source: https://v3-migration.vuejs.org/breaking-changes/key-attribute In Vue 2.x, it was recommended to use `key`s on `v-if`/`v-else`/`v-else-if` branches. This example shows the Vue 2.x syntax. ```html
    Yes
    No
    ``` -------------------------------- ### Vue 3 Event Bus with tiny-emitter Source: https://v3-migration.vuejs.org/breaking-changes/events-api This example demonstrates replacing the Vue 2 event bus with an external library like tiny-emitter in Vue 3. It provides the same event emitter API ($on, $off, $once, $emit). ```javascript import emitter from 'tiny-emitter/instance' export default { $on: (...args) => emitter.on(...args), $once: (...args) => emitter.once(...args), $off: (...args) => emitter.off(...args), $emit: (...args) => emitter.emit(...args) } ``` -------------------------------- ### Vue 2.x Template Loop with v-if on Child and Keys Source: https://v3-migration.vuejs.org/breaking-changes/key-attribute This example shows the Vue 2.x approach for template loops with a `v-if` on a child element, where keys were applied to the child elements. ```html ``` -------------------------------- ### Vue 3 Custom Directive Usage Source: https://v3-migration.vuejs.org/breaking-changes/custom-directives Example of a custom directive in Vue 3 using the beforeMount hook. ```html

    Highlight this text bright yellow

    ``` ```js const app = Vue.createApp({}) app.directive('highlight', { beforeMount(el, binding, vnode) { el.style.background = binding.value } }) ``` -------------------------------- ### 2.x Inline Template Syntax Source: https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute Example of the deprecated inline-template attribute usage in Vue 2.x. ```html

    These are compiled as the component's own template.

    Not parent's transclusion content.

    ``` -------------------------------- ### Define Mixin Data Merge Source: https://v3-migration.vuejs.org/breaking-changes/data-option Example of component and mixin data structures that demonstrate shallow merge behavior. ```javascript const Mixin = { data() { return { user: { name: 'Jack', id: 1 } } } } const CompA = { mixins: [Mixin], data() { return { user: { id: 2 } } } } ``` -------------------------------- ### Using Global Filters in Vue 3 Templates Source: https://v3-migration.vuejs.org/breaking-changes/filters Access globally registered filters via `$filters` in Vue 3 templates. This example shows how to format a balance using the globally available `currencyUSD` filter. ```html ``` -------------------------------- ### Vue 2 Custom Directive Usage Source: https://v3-migration.vuejs.org/breaking-changes/custom-directives Example of a custom directive in Vue 2 using the bind hook. ```html

    Highlight this text bright yellow

    ``` ```js Vue.directive('highlight', { bind(el, binding, vnode) { el.style.background = binding.value } }) ``` -------------------------------- ### Vue 3.x nextTick in Unit Tests Source: https://v3-migration.vuejs.org/breaking-changes/global-api-treeshaking This example demonstrates importing `nextTick` as a named export in Vue 3 for use in unit tests. This is crucial for tree-shaking. ```javascript import { shallowMount } from '@vue/test-utils' import { MyComponent } from './MyComponent.vue' import { nextTick } from 'vue' test('an async feature', async () => { const wrapper = shallowMount(MyComponent) // execute some DOM-related tasks await nextTick() // run your assertions }) ``` -------------------------------- ### Vue 2.x nextTick in Unit Tests Source: https://v3-migration.vuejs.org/breaking-changes/global-api-treeshaking This example shows `Vue.nextTick` usage within a unit test in Vue 2. The global API approach prevents tree-shaking. ```javascript import { shallowMount } from '@vue/test-utils' import { MyComponent } from './MyComponent.vue' test('an async feature', async () => { const wrapper = shallowMount(MyComponent) // execute some DOM-related tasks await wrapper.vm.$nextTick() // run your assertions }) ``` -------------------------------- ### Vue 3.x Template Loop with Keys on Template Tag Source: https://v3-migration.vuejs.org/breaking-changes/key-attribute In Vue 3.x, the `key` should be placed on the `