| No. | \\\\nAPI & Description | \\\\nExample | \\\\n
|---|---|---|
| Create for Server-Side Rendering (SSR) | \\\\ncreateApp() Create a Vue application Example, typically used for client-side rendering. | \\\\n const app = createApp(App) | \\\\n
| Set a global error handler, triggered when uncaught | \\\\ncreateSSRApp() Create for Server-Side Rendering (SSR)'s Vue Application Example. | \\\\n const app = createSSRApp(App) | \\\\n
| errors occur in the application. | \\\\napp.mount() Set Vue Application Example mounted to specified's DOM On the element. | \\\\n app.mount('#app') | \\\\n
| compilation behavior. | \\\\napp.unmount() Unmount the Vue application Example. | \\\\n app.unmount() | \\\\n
| Configure the template compiler | \\\\napp.onUnmount() Register during unmount'sCallback function. | \\\\n app.onUnmount(() => { console.log('App is being unmounted') }) | \\\\n
| Set a global warning handler to handle | \\\\napp.component() Register global components, making them available anywhere. | \\\\n app.component('MyComponent', MyComponent) | \\\\n
| Define component option merging strategies, controlling how component | \\\\napp.directive() Register global directives, allowing the creation of custom directives. | \\\\n app.directive('focus', { mounted(el) { el.focus() } }) | \\\\n
| callback functions. | \\\\napp.use() Install plugins, which can provide additional features for the application. | \\\\n app.use(SomePlugin) | \\\\n
| Global configuration. | \\\\napp.mixin() Register global mixins, providing shared data or methods to all components. | \\\\n app.mixin({ methods: { globalMethod() { ... } } }) | \\\\n
| Create for Server-Side Rendering (SSR)0 | \\\\napp.provide() Provide dependencies to the entire application, sharing data across components. | \\\\n app.provide('key', 'some value') | \\\\n
| Create for Server-Side Rendering (SSR)Create for Server-Side Rendering (SSR) | \\\\napp.runWithContext()Run a function in the Vue app context, allowing access to context data. | \\\\n app.runWithContext(() => { console.log('Running inside app context') }) | \\\\n
| Create for Server-Side Rendering (SSR)Set a global error handler, triggered when uncaught | \\\\napp.version Get Vue current'sVersion number. | \\\\n console.log(app.version) | \\\\n
| Create for Server-Side Rendering (SSR)errors occur in the application. | \\\\napp.config Get and set Application Example'sGlobal configuration. | \\\\n app.config.globalProperties.$myProperty = 'value' | \\\\n
| Create for Server-Side Rendering (SSR)compilation behavior. | \\\\napp.config.errorHandler Set global error handling function, triggered when uncaught errors occur in the application'sTriggered when errors occur. | \\\\n app.config.errorHandler = (err, vm, info) => { console.error(err) } | \\\\n
| Create for Server-Side Rendering (SSR)Configure the template compiler | \\\\napp.config.warnHandler Set global warning handling function, handle warnings in the application'sWarning messages. | \\\\n app.config.warnHandler = (msg, vm, trace) => { console.warn(msg) } | \\\\n
| Create for Server-Side Rendering (SSR)Set a global warning handler to handle | \\\\napp.config.performance Enable performance monitoring, providing rendering performance data. | \\\\n app.config.performance = true | \\\\n
| Create for Server-Side Rendering (SSR)Define component option merging strategies, controlling how component | \\\\napp.config.compilerOptions Configure template compiler'sOptions, control template'sCompilation behavior. | \\\\n app.config.compilerOptions.delimiters = ['[[', ']]'] | \\\\n
| Create for Server-Side Rendering (SSR)callback functions. | \\\\napp.config.globalProperties Set global properties accessible by all components in the application. | \\\\n app.config.globalProperties.$myGlobalProperty = 'value' | \\\\n
| Create for Server-Side Rendering (SSR)Global configuration. | \\\\napp.config.optionMergeStrategies Define component options merge strategy, control how to merge components'sOptions. | \\\\n app.config.optionMergeStrategies.methods = (parent, child) => { return { ...parent, ...child } } | \\\\n
| Set a global error handler, triggered when uncaught0 | \\\\napp.config.idPrefixSet the prefix for Vue instance IDs, default is "vue-". | \\\\n app.config.idPrefix = 'myApp-' | \\\\n
| Set a global error handler, triggered when uncaughtCreate for Server-Side Rendering (SSR) | \\\\napp.config.throwUnhandledErrorInProduction Control whether unhandled errors are thrown in production environment'sErrors. | \\\\n app.config.throwUnhandledErrorInProduction = false | \\\\n
| Set a global error handler, triggered when uncaughtSet a global error handler, triggered when uncaught | \\\\nversion Get Vue current'sVersion number. | \\\\n console.log(Vue.version) | \\\\n
| Set a global error handler, triggered when uncaughterrors occur in the application. | \\\\nnextTick()Execute delayed callback after DOM update is complete, used for handling asynchronous DOM updates. | \\\\n nextTick(() => { console.log('DOM updated') }) | \\\\n
| Set a global error handler, triggered when uncaughtcompilation behavior. | \\\\ndefineComponent() Used to define components, providing type inference and more concise'sSyntax. | \\\\n export default defineComponent({ name: 'MyComponent' }) | \\\\n
| Set a global error handler, triggered when uncaughtConfigure the template compiler | \\\\ndefineAsyncComponent() Define async components that are lazily loaded when needed. | \\\\n const AsyncComponent = defineAsyncComponent(() => import('./AsyncComponent.vue')) | \\\\n
Function: Creates a Vue application instance.
\\\\nUsage: `createApp(rootComponent, rootProps)
\\\\nParameters:
\\\\n- \\\\n
- `rootComponent`: The root component. \\\\n
- `rootProps` (optional): Props to pass to the root component. \\\\n
import { createApp } from 'vue';\\\\nimport App from './App.vue';\\\\nconst app = createApp(App);\\\\nFunction: Creates a Vue application instance that supports Server-Side Rendering (SSR).
\\\\nUsage: `createSSRApp(rootComponent, rootProps)
\\\\nParameters:
\\\\n- \\\\n
- `rootComponent`: The root component. \\\\n
- `rootProps` (optional): Props passed to the root component. \\\\n
import { createSSRApp } from 'vue';\\\\nimport App from './App.vue';\\\\nconst app = createSSRApp(App);\\\\nFunction: Mounts the application to a DOM element.
\\\\nUsage: `app.mount(container)
\\\\nParameters:
\\\\n- \\\\n
- `container`: DOM element or selector string. \\\\n
app.mount('#app');\\\\nFunction: Unmount the application instance.
\\\\nUsage: `app.unmount()`
\\\\napp.unmount();\\\\nFunction: Registers a callback function that is called when the application is unmounted.
\\\\nUsage: `app.onUnmount(callback)
\\\\nParameters:
\\\\n- \\\\n
- `callback`: The function to be called when unmounted. \\\\n
app.onUnmount(() => {\\\\n console.log('App unmounted');\\\\n});\\\\nFunction: Register or retrieve a global component.
\\\\nUsage:
\\\\n- \\\\n
- Register: `app.component(name, component) \\\\n
- Retrieve: `app.component(name) \\\\n
Parameters:
\\\\n- \\\\n
- `name`: The component name. \\\\n
- `component`: The component definition. \\\\n
app.component('MyComponent', {\\\\n template: 'My Component'\\\\n});\\\\nFunction: Register or retrieve a global directive.
\\\\nUsage:
\\\\n- \\\\n
- Register: `app.directive(name, directive) \\\\n
- Retrieve: `app.directive(name) \\\\n
Parameters:
\\\\n- \\\\n
- `name`: Directive name. \\\\n
- `directive`: Directive definition. \\\\n
app.directive('focus', {\\\\n mounted(el) {\\\\n el.focus();\\\\n }\\\\n});\\\\nFunction: Installs a plugin.
\\\\nUsage: `app.use(plugin, options)
\\\\nParameters:
\\\\n- \\\\n
- `plugin`: The plugin. \\\\n
- `options` (optional): Plugin options. \\\\n
import MyPlugin from './MyPlugin';\\\\napp.use(MyPlugin);\\\\nFunction: Global mixin options.
\\\\nUsage: `app.mixin(mixin)
\\\\nParameters:
\\\\n- \\\\n
- `mixin`: The mixin object. \\\\n
app.mixin({\\\\n created() {\\\\n console.log('Global mixin created');\\\\n }\\\\n});\\\\nFunction: Provides global dependencies.
\\\\nUsage: `app.provide(key, value)
\\\\nParameters:
\\\\n- \\\\n
- `key`: Dependency name. \\\\n
- `value`: Dependency value. \\\\n
app.provide('theme', 'dark');\\\\nFunction: Runs a function within the current application context.
\\\\nUsage: `app.runWithContext(fn)
\\\\nParameters:
\\\\n- \\\\n
- `fn`: The function to run. \\\\n
app.runWithContext(() => {\\\\n console.log('Running with app context');\\\\n});\\\\nFunction: Get the Vue version.
\\\\nUsage: `app.version
\\\\nconsole.log(app.version);\\\\nFeature: Application configuration object.
\\\\nUsage: `app.config
\\\\napp.config.errorHandler = (err) => {\\\\n console.error(err);\\\\n};\\\\nFunction: Global error handling function.
\\\\nUsage: `app.config.errorHandler = (err, vm, info) => {}`
\\\\nParameters:
\\\\n- \\\\n
- `err`: Error object. \\\\n
- `vm`: Component instance where the error occurred. \\\\n
- `info`: Error information. \\\\n
app.config.errorHandler = (err) => {\\\\n console.error('Global error:', err);\\\\n};\\\\nFunction: Global warning handler.
\\\\nUsage: `app.config.warnHandler = (msg, vm, trace) => {}`
\\\\nParameters:
\\\\n- \\\\n
- `msg`: Warning message. \\\\n
- `vm`: Component instance where the warning occurred. \\\\n
- `trace`: Warning stack trace. \\\\n
app.config.warnHandler = (msg) => {\\\\n console.warn('Global warning:', msg);\\\\n};\\\\nFunction: Enables performance tracking.
\\\\nUsage: `app.config.performance = true
\\\\napp.config.performance = true;\\\\nFunction: Configure options for the template compiler.
\\\\nUsage: `app.config.compilerOptions = { /* options */ }
\\\\napp.config.compilerOptions = { whitespace: 'preserve' };\\\\nFunction: Add global properties.
\\\\nUsage: `app.config.globalProperties = value
\\\\napp.config.globalProperties.$myGlobal = 'Hello';\\\\nFunction: Custom option merge strategies.
\\\\nUsage: `app.config.optionMergeStrategies = strategy
\\\\napp.config.optionMergeStrategies.customOption = (parent, child) => {\\\\n return child || parent;\\\\n};\\\\nFunction: Sets the component ID prefix.
\\\\nUsage: `app.config.idPrefix = 'my-app-'`
\\\\napp.config.idPrefix = 'my-app-';\\\\nFunction: Throw unhandled errors in production environment.
\\\\nUsage: `app.config.throwUnhandledErrorInProduction = true
\\\\napp.config.throwUnhandledErrorInProduction = true;\\\\nFeature: Get the Vue version.
\\\\nUsage: `Vue.version
\\\\nconsole.log(Vue.version);\\\\nFunction: Execute callback after the next DOM update cycle ends.
\\\\nUsage: `nextTick(callback)
\\\\nParameters:
\\\\n- \\\\n
- `callback`: Callback function. \\\\n
import { nextTick } from 'vue';\\\\nnextTick(() => {\\\\n console.log('DOM updated');\\\\n});\\\\nFunction: Defines a component.
\\\\nUsage: `defineComponent(options)
\\\\nParameters:
\\\\n- \\\\n
- `options`: Component options. \\\\n
import { defineComponent } from 'vue';\\\\nconst MyComponent = defineComponent({\\\\n template: 'My Component'\\\\n});\\\\n
YouTip