Detailed explanation of the use cases of Vue listeners

Detailed explanation of the use cases of Vue listeners

The first one is to use jQuery's ajax to send a request

When a user registers, a listener can be used to determine whether the user name is repeated. The listener uses watch. If you need to monitor the change of a value, put the value in the watch.

Get the new value, call the interface, request the backend, and determine whether the username already exists.

At this point, the problem encountered is that the listener is not triggered when the user refreshes the page, but only when the username value changes. The improvement method is to change the method format listener to an object format listener.

The method-format listener is recommended first (the simplest). If it needs to be executed once when it is refreshed, it is defined as an object listener.

When an object has multiple attributes, we must use object-format monitoring. If any attribute change of the required object can trigger the listener, the deep attribute must be enabled.

When the object has multiple properties, turn on deep:true.

If you want to monitor changes in a sub-property of an object, use the following syntax:

Summarize:

This is the end of this article about the use cases of vue listeners. For more information about the use of vue listeners, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue programmatic event listener (detailed example solution)
  • Explanation of the use of Vue computed attributes, events, and listeners watch
  • Vue two-way data binding implementation learning listener implementation method
  • Vue.js binding event listener example [based on v-on event binding]
  • Vue computed properties and listener instance analysis

<<:  Tomcat Nginx Redis session sharing process diagram

>>:  MySQL database advanced query and multi-table query

Recommend

Undo log in MySQL

Concept introduction: We know that the redo log i...

Solve the 1251 error when establishing a connection between mysql and navicat

I reinstalled the computer and installed the late...

Easyswoole one-click installation script and pagoda installation error

Frequently asked questions When you are new to ea...

Why should you be careful with Nginx's add_header directive?

Preface As we all know, the nginx configuration f...

How to install and deploy MySQL 8.0 under CentOS8

MySQL 8 official version 8.0.11 has been released...

Implementation of Docker Compose multi-container deployment

Table of contents 1. WordPress deployment 1. Prep...

Detailed deployment of Alibaba Cloud Server (graphic tutorial)

I have recently learned web development front-end...

Win2008 R2 mysql 5.5 zip format mysql installation and configuration

Win2008 R2 zip format mysql installation and conf...

Ubuntu installation cuda10.1 driver implementation steps

1. Download cuda10.1: NVIDIA official website lin...

IE8 Developer Tools Menu Explanation

<br />This article has briefly explained the...

A brief discussion on why daemon off is used when running nginx in docker

I'm very happy. When encountering this proble...

JS implements user registration interface function

This article example shares the specific code of ...