In this article, we have listed easy ways to create Vue API. Read this full article, to understand the instances better. Install Vue in your system, if you haven’t already. This will be integrated into your Vuejs project that will allow you to build a basic Vue app.
# 1: createApp()
Create an app instance
Enter the following code
Example:
Use code with inline root component:
Use with imported component:
# 2: createSSRApp()
Use SSR Hydration mode to create an app instance. The usage is the same as createApp().
# 3: app.mount()
Use the corner element to mount the app instances.
Enter the following code
Example
You can also mount to DOM element
# 4: app.unmount()
Unmount all the mounted app instances this will trigger the unmount lifecycle hooks for all kinds of components in the app’s component tree. This will help you integrate API into your Vue application.
Enter the following code
# 5: app.provide()
Enter the value which can be used in all descendant components within the app.
Enter the following code
Example
Inside a component in the app
# 6: app.component()
Create Vuejs API with this component. While passing both a component definition and name string, register a global component. It may retrieve an already one in case the name is passed.
Enter the following code
Example
# 7: app.directive()
This Vuejs API will make your app more interactive. In case you are passing both directive definition and name string, register a global custom directive. It might retrieve an already registered one only if the name is passed.
Enter the following code
Example
#8 app.use()
First install a plugin
Enter the following code
Example
#9 app.version
Give the Vue version that your app is created with. It will help you inside plugins, where you might need conditional logic which is based on different versions of Vue.
Enter the following code
Example
This will help you perform a version check inside a plugin
#9 app.config
Every app instance provides a config element that inculcates the config setting for that app. You can modify its features before mounting your app.
#10 app.config.errorHandler
This will help you provide a global handler for uncaught errors from within the app.
Enter the following code
Example
#11 app.config.warnHandler
Provide a custom handler from Vue for runtime warnings
Enter the following code
Example
#11 app.config,.performace
To enable compile, component init, patch and render performance tracing in the browser timeline panel/ devtool performance, set this config to true. Only work in browser and development mode that supports the API name performance.mark.
Enter boolean
#12 app.config.compilerOptions
Configuration of the runtime compiler options. All the values set on this kind of object will be transferred to the in-browser template compiler and this will affect all components in the config application. Remember that you will also override all these options on a per-component basis using the compileroptions options.
#app.config.compilerOptions.isCustomElement
This specifies a check method in order to recognize native custom options.
Enter: (tag: string) => boolean
Example
#app.config.compilerOptions.whitespace
This will allow you to adjust whitespace handling behaviour template
Enter: 'condense' | 'preserve'
Default: 'condense'
Example
#app.config.compilerOptions.comments
This will allow you to adjust HTML components treatment in templates
Enter: boolean
Default: false
Example
#13 app.config.globalProperties
It is an object which can be used on any component instance and can be registered on global properties inside the app.
Enter the following code
Usage
This allows msg to be available inside any component template inside the app, plus on this of any component instance:
#14 app.config.optionMergeStrategies
It is an object for describing merging strategies for custom component options.
Enter the following code
Example
In our previous blog we have also talked about firebase authentication for your Vue application.
No comments:
Post a Comment