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

Parsing the commonly used v-instructions in vue.js

Table of contents Explanation of v-text on if for...

Docker Swarm from deployment to basic operations

About Docker Swarm Docker Swarm consists of two p...

JS implements user registration interface function

This article example shares the specific code of ...

How to use Typescript to encapsulate local storage

Table of contents Preface Local storage usage sce...

Vue code highlighting plug-in comprehensive comparison and evaluation

Table of contents Comprehensive comparison From t...

Complete steps to build a Laravel development environment using Docker

Preface In this article, we will use Docker to bu...

15-minute parallel artifact GNU Parallel Getting Started Guide

GNU Parallel is a shell tool for executing comput...

Detailed tutorial on how to install mysql8.0 using Linux yum command

1. Do a good job of cleaning before installation ...

About WeChat Mini Program to implement cloud payment

Table of contents 1. Introduction 2. Thought Anal...

Linux editing start, stop and restart springboot jar package script example

Preface In the springboot configuration file, the...

Share the responsive frameworks commonly used by web design masters (summary)

This article introduces and shares the responsive...