Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use listeners in vue

Shulou Source: shulou.com Published: 2022-06-03 15:03:41 10月04日 Update

This article mainly shows you "how to use listeners in vue". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to use listeners in vue".

First, send a request using jquery's ajax

When a user registers, it is determined that the user name cannot be duplicated and a listener can be used. The listener, with watch, will put this value in the watch if it needs to listen for a change in the value.

Get the new value, call the API, request the backend, and determine whether the user name already exists.

At this point, when the user refreshes the page, the listener is not triggered, but only when the username value changes. The improved method is to change the method-formatted listener to the object-formatted listener.

A listener in the preferred method format (the simplest) is defined as an object listener if it needs to be executed once refreshed in.

When an object has multiple properties, we must listen in object format. If any property of the required object changes, the listener can be triggered, and the deep property must be turned on.

When the object has more than one property, open deep:true.

If you are listening for a change in a child property of an object, write it as follows:

Summary:

The above is all the contents of the article "how to use listeners in vue". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Listener listener object property format user content method time article change listener multiple user name learning help size writing just interface Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi MySQL Shulou Tech Info OPPO Reno