Vue custom plug in


1. Create a new JS file utils.js, custom method

let local = {
    say() {
        Console. Log ('I'm a custom method in plug-ins')
export default {
    install: function(vm) {
        vm.prototype.$local = local

2. Mian.js introduces plug-ins and injects instances

//Import plug-ins
import utils from './utils/utils'
Vue. Use (utils) // inject Vue instance

3. Component call

This. $local. Say() // I am a custom method in the plug-in



Recommended Today

[Redis5 source code learning] analysis of the randomkey part of redis command

baiyan Command syntax Command meaning: randomly return a key from the currently selected databaseCommand format: RANDOMKEY Command actual combat:> keys * 1) “kkk” 2) “key1”> randomkey “key1”> randomkey “kkk” Return value: random key; nil if database is empty Source code analysis Main process The processing function corresponding to the keys command is […]