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

React+axios implements github search user function (sample code)

load Request Success Request failed Click cmd and...

What you need to know about msyql transaction isolation

What is a transaction? A transaction is a logical...

A brief discussion on using virtual lists to optimize tables in el-table

Table of contents Preface Solution Specific imple...

HeidiSQL tool to export and import MySQL data

Sometimes, in order to facilitate the export and ...

Briefly explain the use of group by in sql statements

1. Overview Group by means to group data accordin...

Vue event's $event parameter = event value case

template <el-table :data="dataList"&...

The difference between key and index in MySQL

Let's look at the code first: ALTER TABLE rep...

Solution to the inconsistency between crontab execution time and system time

Preface In LINUX, periodic tasks are usually hand...

How to install mysql5.6 in docker under ubuntu

1. Install mysql5.6 docker run mysql:5.6 Wait unt...

How to Communicate with Other Users on the Linux Command Line

It's easy to send messages to other users in ...

Common naming rules for CSS classes and ids

Public name of the page: #wrapper - - The outer e...

Summary of the differences between Html, sHtml and XHtml

For example: <u> This has no ending characte...

Three Ways to Lock and Unlock User Accounts in Linux

If you already have some kind of password policy ...

The complete process of Docker image creation

Table of contents Preface Creation steps Create a...