Home Web Front-end JS Tutorial Summary of vue.js event handler examples

Summary of vue.js event handler examples

Jun 29, 2017 pm 03:47 PM
javascript vue.js processor

This article mainly introduces the detailed explanation of vue.jseventprocessor v-on:click. The editor thinks it is quite good, so I will share it now. For everyone, and as a reference for everyone. Let’s follow the editor and take a look.

Use the v-on command to monitor DOM events

Note: v-on cannot be used in HTML5, replace it with @

(1) html code:

<p id="example"> 
 <button v-on:click="greet">Greet</button> 
 // 或者 

<button @click="greet">Greet</button> 
</p>
Copy after login

(2) js code:

var vm = new Vue({ 
 el: &#39;#example&#39;, 
 data: { 
 name: &#39;Vue.js&#39; 
 }, 
 // 在 `methods` 对象中定义方法 
 methods: { 
 greet: function (event) { 
  // 方法内 `this` 指向 vm 
  alert(&#39;Hello &#39; + this.name + &#39;!&#39;) 
  // `event` 是原生 DOM 事件 
  alert(event.target.tagName) 
 } 
 } 
})
Copy after login

(3) Effect display:

The above is the detailed content of Summary of vue.js event handler examples. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
AMD announces 'Sinkclose' high-severity vulnerability, affecting millions of Ryzen and EPYC processors AMD announces 'Sinkclose' high-severity vulnerability, affecting millions of Ryzen and EPYC processors Aug 10, 2024 pm 10:31 PM

According to news from this site on August 10, AMD officially confirmed that some EPYC and Ryzen processors have a new vulnerability called "Sinkclose" with the code "CVE-2023-31315", which may involve millions of AMD users around the world. So, what is Sinkclose? According to a report by WIRED, the vulnerability allows intruders to run malicious code in "System Management Mode (SMM)." Allegedly, intruders can use a type of malware called a bootkit to take control of the other party's system, and this malware cannot be detected by anti-virus software. Note from this site: System Management Mode (SMM) is a special CPU working mode designed to achieve advanced power management and operating system independent functions.

Intel Core Ultra 9 285K processor exposed: single-core running score is 4% faster than Ryzen 9 9950X and multi-core is 14% faster Intel Core Ultra 9 285K processor exposed: single-core running score is 4% faster than Ryzen 9 9950X and multi-core is 14% faster Aug 21, 2024 pm 04:46 PM

According to news from this website on August 21, technology media WccFtech reported today that the Intel Core Ultra9285K "ArrowLake" processor appeared in the GeekBench6 benchmark library, surpassing the Core i9-14900KS and Ryzen99950X processors. Test platform The test platform exposed this time is ASUS ROGSTRIXZ890-AGamingWIFI motherboard and 64GBDDR5-6400 memory. Introduction to the Intel Core Ultra9285K "ArrowLake-S" desktop processor. The PL1 power consumption of the Intel Core Ultra9285K processor is 125W and it uses a 7nm process (CPU-Z information, it should actually use UK

The difference between multithreading and asynchronous c# The difference between multithreading and asynchronous c# Apr 03, 2025 pm 02:57 PM

The difference between multithreading and asynchronous is that multithreading executes multiple threads at the same time, while asynchronously performs operations without blocking the current thread. Multithreading is used for compute-intensive tasks, while asynchronously is used for user interaction. The advantage of multi-threading is to improve computing performance, while the advantage of asynchronous is to not block UI threads. Choosing multithreading or asynchronous depends on the nature of the task: Computation-intensive tasks use multithreading, tasks that interact with external resources and need to keep UI responsiveness use asynchronous.

Vue.js vs. React: Project-Specific Considerations Vue.js vs. React: Project-Specific Considerations Apr 09, 2025 am 12:01 AM

Vue.js is suitable for small and medium-sized projects and fast iterations, while React is suitable for large and complex applications. 1) Vue.js is easy to use and is suitable for situations where the team is insufficient or the project scale is small. 2) React has a richer ecosystem and is suitable for projects with high performance and complex functional needs.

Free choice of power consumption? Sources claim AMD will unlock 105W TDP configuration for R5 9600X and R7 9700X via AGESA 1.2.0.1a update Free choice of power consumption? Sources claim AMD will unlock 105W TDP configuration for R5 9600X and R7 9700X via AGESA 1.2.0.1a update Aug 15, 2024 am 07:38 AM

According to news from this site on August 14, two of the AMD Ryzen 9000 series desktop processors (R59600X and R79700X) were officially launched on August 8, priced at 1,949 yuan and 2,549 yuan respectively. Although the TDP of these two processors has been significantly reduced (65W) and the initial price has also been reduced, compared with the previous generation Ryzen 7000 series, the performance has only been improved by about 10% or even single-digit percentages. This is for some users who are more performance-oriented. It may be difficult for players to accept it. Considering this situation, it may be a good solution to let players decide the level of performance release. @g01d3nm4ng0 said that AMD will pass the AGESA1.2.0.1aPatchA microcode patch to Ryzen

Is vue.js hard to learn? Is vue.js hard to learn? Apr 04, 2025 am 12:02 AM

Vue.js is not difficult to learn, especially for developers with a JavaScript foundation. 1) Its progressive design and responsive system simplify the development process. 2) Component-based development makes code management more efficient. 3) The usage examples show basic and advanced usage. 4) Common errors can be debugged through VueDevtools. 5) Performance optimization and best practices, such as using v-if/v-show and key attributes, can improve application efficiency.

Is Vue used for frontend or backend? Is Vue used for frontend or backend? Apr 03, 2025 am 12:07 AM

Vue.js is mainly used for front-end development. 1) It is a lightweight and flexible JavaScript framework focused on building user interfaces and single-page applications. 2) The core of Vue.js is its responsive data system, and the view is automatically updated when the data changes. 3) It supports component development, and the UI can be split into independent and reusable components.

How to obtain Bitcoin? A list of all ways to obtain Bitcoin How to obtain Bitcoin? A list of all ways to obtain Bitcoin Feb 15, 2025 pm 11:24 PM

Bitcoin is a digital currency that can be obtained in many ways. This article will introduce different approaches, including purchasing, mining, receiving rewards, accepting payments, Bitcoin loans through an exchange or broker, and providing factors to consider when choosing the best approach, such as fees, speed, convenience, and risk. .

See all articles