In vue, how to use trigger to simulate blur events and find the code. Use element-ui at the same time

the elemnt-ui used. Want to simulate blur events. Find the code

Jul.06,2021

html

<input type='text' ref='input' />

js

this.$refs.input.blur()

Let's have a universal version that triggers arbitrary events (including custom events) to any element other than abstract component tags such as template, transition, etc., which can be native dom tags, custom component tags or even elements looped by v-for. For example, trigger the "foo" event to the tag)

html

< ref="xx" />

js

import Vue from "vue"

export default {
    methods:{
        // xxdom
        findDom(target){
            target = target || this.$refs.xx;
            // dom
            let doms = [];
            if(target instanceof Vue){
                doms.push(target.$el);
            }else if(target instanceof window.Element){
                doms.push(target);
            }else if(Array.isArray(target)){
                target.forEach(t=>{
                    doms = doms.concat(this.findDom(t))
                });
            }
            return doms;
        },
        // xxrefdom
        triggerEvent(eventName){
            eventName = String(eventName);
            const event = new Event(eventName);
            const doms = this.findDom();
            if(doms.length){
                doms.forEach(dom=>{
                    dom.dispatchEvent(event)
                });
            }else{
                throw new Error("dom")
            }
        }
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7ced-46bc9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7ced-46bc9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?