Solution to automatically trigger click events when clicking on pop-up window in Vue (simulation scenario)

Solution to automatically trigger click events when clicking on pop-up window in Vue (simulation scenario)

Business scenario: Use vue + element ui's el-dialog. After clicking the pop-up window, the data of the first button is loaded by default for initialization.

div

instruction:

 // Automatically trigger click events directives:{
        trigger:{
          inserted(el,binging){
            // console.log("Automatically trigger events")
            el.click()
          }
        }
  },

PS: Let's take a look at vue automatically triggering click events

Yes, click on the list on the left to get the details, but a click event is required. When the page comes in, the click event is triggered by default.

Method 1, vue custom instructions

  directives:{
    trigger:{
     inserted(el, binging){
        console.log(el.id)
        el.id == 'nav0' ? el.click() : null // Only click the first one, the id is manually added in the loop // $(el).trigger('click') // All are triggered once, then the last one}
    }
  },

usage:

 <span class="nav-item" :id="'nav' + index" v-trigger :class="{'active': item.stage == activeId}" @click="navClick(item)" v-for="(item, index) in nav" :key="item.stage">{{item.stage_name}}</span>

The above is the detailed content of the solution (simulated scenario) for automatically triggering click events by clicking on the pop-up window of Vue. For more information about automatically triggering click events of Vue, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • How to realize automatic triggering function in Vue
  • Vue manually controls the click event Click triggering method
  • Vue triggers input to select file click event operation
  • Actively trigger click events in vue

<<:  Linux 6 steps to change the default remote port number of ssh

>>:  Detailed explanation of the performance monitoring ideas of specified processes in Linux system based on Python

Recommend

Google Translate Tool: Quickly implement multilingual websites

Google China has released a translation tool that ...

Detailed explanation of the use of find_in_set() function in MySQL

First, let’s take an example: There is a type fie...

TypeScript namespace merging explained

Table of contents Merge namespaces with the same ...

Directory permissions when creating a container with Docker

When I was writing a project yesterday, I needed ...

JavaScript implements single linked list process analysis

Preface: To store multiple elements, arrays are t...

How to implement the prototype pattern in JavaScript

Overview The prototype pattern refers to the type...

IIS7 IIS8 reverse proxy rule writing, installation and configuration method

Purpose: Treat Station A as the secondary directo...

MySQL import and export backup details

Table of contents 1. Detailed explanation of MySQ...

JavaScript timer to achieve seamless scrolling of pictures

This article shares the specific code of JavaScri...

Talk about the understanding of CSS attribute margin

1.What is margin? Margin is used to control the sp...

Analysis of the Linux input subsystem framework principle

Input subsystem framework The linux input subsyst...

MySQL 5.7.18 Installer installation download graphic tutorial

This article records the detailed installation tu...