Introduction to install method in Vue

Introduction to install method in Vue

vue provides install for us to develop new plug-ins and globally register components, etc.

The first parameter of the install method is the vue constructor, and the second parameter is an optional options object

export default {

	install(Vue,option){

		Component directive mixin mount vue prototype }

}

1. Globally registered components

import PageTools from '@/components/PageTools/pageTools.vue'

import update from './update/index.vue'

import ImageUpload from './ImageUpload/ImageUpload.vue'

import ScreenFull from './ScreenFull'

import ThemePicker from './ThemePicker'

import TagsView from './TagsView'

export default {

  install(Vue) {

    Vue.component('PageTools', PageTools)

    Vue.component('update', update)

    Vue.component('ImageUpload', ImageUpload)

    Vue.component('ScreenFull', ScreenFull)

    Vue.component('ThemePicker', ThemePicker)

    Vue.component('TagsView', TagsView)

  }

}

In main.js, directly use reference and Vue.use to register

import Component from '@/components'

Vue.use(Component)

2. Global custom instructions

export default{

	install(Vue){

		Vue.directive('pre',{

			inserted(button,bind){

				button.addEventListener('click',()=>{

					if(!button.disabled){

						button.disabled = true;

						setTimeout(()=>{

							button.disabled = false

						},1000)

					}

				})

			}

		})

	}

}

In main.js, just like registering components

import pre from '@/aiqi'

Vue.use(pre)

This is the end of this article about the install method in vue. For more relevant content about the install method in vue, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • In-depth understanding of Vue's plug-in mechanism and installation details
  • vue npm install install a specified version operation
  • vue custom component (used by Vue.use()) is the usage of install
  • Vue Pitfalls - Installing dependent modules in the project npm install reports an error

<<:  Linux Samba server super detailed installation and configuration (with problem solving)

>>:  Solve the problem that the name of the type=file file modification form cannot be echoed normally

Recommend

Detailed explanation of the use of Linux seq command

01. Command Overview The seq command is used to g...

A brief discussion on JavaScript throttling and anti-shake

Table of contents Throttling and anti-shake conce...

Implementation of Docker packaging image and configuration modification

I have encountered many problems in learning Dock...

Solve the problem of using linuxdeployqt to package Qt programs in Ubuntu

I wrote some Qt interface programs, but found it ...

JS+Canvas realizes dynamic clock effect

A dynamic clock demo based on Canvas is provided ...

CSS float (float, clear) popular explanation and experience sharing

I came into contact with CSS a long time ago, but...

Achieve 3D flip effect with pure CSS3 in a few simple steps

As a required course for front-end developers, CS...

A brief analysis of HTML space code

How much do you know about HTML? If you are learni...

How to Apply for Web Design Jobs

<br />Hello everyone! It’s my honor to chat ...

Complete steps to reset the root user password in mysql8

Preface Recently, many new colleagues have asked ...