This article example shares the specific code of Vue to verify whether the username is available for your reference. The specific content is as follows Verify that the username is availableCase EffectImplementation steps (ideas) 1. Data binding through v-model Further adjustments are 1. Use a listener to monitor changes in user names CodeBasic layout <div id="app"> <span>Username:</span> <span> <input type="text" v-model.lazy="uname"> </span> <span> {{tip}} </span> </div> Implement specific functions through listeners <script type="text/javascript" src="../js/vue.js"></script> <script type="text/javascript"> /* Listener uses the listener to monitor changes in the user name. If the user name changes (call the background interface for verification) Adjust the prompt information according to the verification results*/ var vm = new Vue({ el: "#app", data: { uname: '', tip: '' }, methods: { checkName: function (uname) { //Call the interface, but you can use the scheduled task to simulate the interface call var that = this; setTimeout(function () { // Simulate interface call if (uname == 'admin') { that.tip = 'The user name already exists, please change it' } else { that.tip = 'Username can be used' } }, 1000) } }, watch: uname: function (val) { //Call the backend interface to verify the legitimacy of the user name this.checkName(val); this.tip = 'Verifying...' } }, }); </script> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Steps to install MySQL 5.7.10 on Windows server 2008 r2
>>: Detailed explanation of crontab scheduled execution command under Linux
The default submission method of html is get inste...
Table of contents Overview Global hook function R...
Readonly and Disabled both prevent users from chan...
Table of contents Preface 1. Binary Tree 1.1. Tra...
Having used MySQL for such a long time, I believe...
1. Let's look at a table creation statement f...
This article shares the installation tutorial of ...
1. If MySQL is not started successfully, check th...
Table of contents Preface: accomplish: Summarize:...
Sprites: In the past, each image resource was an ...
Recently, the company has begun to evaluate all s...
Table of contents Implementation ideas: Step 1: C...
Table of contents 1. Create a watermark Js file 2...
Part.0 Background The company's intranet serv...
【Foreword】 If you want to use ORM to operate data...