


Element UI autocomplete component and form verification conflict: How to solve the problem of form verification failure?
Apr 04, 2025 pm 07:03 PMElement UI auto-completion solution for component-form verification conflict
When using the el-autocomplete
component of Element UI, you often encounter the problem of form verification failure: even if the user has selected the drop-down option and the input box displays the correct value, the form still prompts that it has not been filled in. This article analyzes this problem and provides solutions.
Problem description:
The form uses el-autocomplete
component to implement username selection and uses el-form-item
and prop
properties to verify. select
event of el-autocomplete
binds a function that handles user selection logic. However, after the user selects, the form verification still fails, prompting "Please enter the user name".
Code example:
Component code:
<el-form-item label="用戶名" prop="username"> <el-autocomplete :fetch-suggestions="querysearch" class="usernameinput" placeholder="選擇或輸入用戶名" v-model="selectuserinfo"> </el-autocomplete> </el-form-item>
Verification rules:
rules: { username: [{ required: true, message: 'Please enter the username', trigger: 'blur' }], password: [{ required: true, message: 'Please enter password', trigger: 'blur' }] },
Related functions:
selection(params) { console.log(this.selectuserinfo); this.loginform.username = params.username; this.loginform.password = atob(params.password); }, onblur() { console.log('blur'); console.log(this.loginform.username, this.selectuserinfo); this.loginform.username = this.selectuserinfo; },
Problem analysis and solution:
The root of the problem is that directly assigning this.loginform.username = params.username
may destroy Vue's responsive mechanism. Vue's responsive system relies on data changes to trigger view updates and form verification. Directly modify the object properties, Vue cannot track changes, resulting in form verification that cannot be updated.
Solution:
-
Ensure
loginform.username
responsiveness: Ifloginform
is a normal JavaScript object, direct assignment will not trigger Vue responsive updates. Updateloginform.username
using theVue.set
method or object expansion operator to ensure that Vue tracks data changes.selection(params) { this.$set(this.loginform, 'username', params.username); // Use Vue.set this.loginform.password = atob(params.password); }
or:
selection(params) { this.loginForm = { ...this.loginForm, username: params.username }; // Object expansion operator this.loginForm.password = atob(params.password); }
Check
trigger
attribute:trigger: 'blur'
triggers only if the input box loses focus. The selection operation ofel-autocomplete
may not triggerblur
event. Try modifyingtrigger
attribute to'change'
or using'blur'
and'change'
at the same time, or selecting the appropriate trigger event based on the actual situation.Check
v-model
binding andloginform
initialization: Make sure thatv-model
binding data is correct and thatloginform
object is correctly initialized as a responsive object.
Through the above methods, the Element UI can solve the problem of conflict between components and form verification by automatically completing the Element UI to ensure the accuracy of form verification.
The above is the detailed content of Element UI autocomplete component and form verification conflict: How to solve the problem of form verification failure?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The garbled problem in Java Chinese is mainly caused by inconsistent character encoding. The repair method includes ensuring the consistency of the system encoding and correctly handling encoding conversion. 1.Use UTF-8 encoding uniformly from files to databases and programs. 2. Clearly specify the encoding when reading the file, such as using BufferedReader and InputStreamReader. 3. Set the database character set, such as MySQL using the ALTERDATABASE statement. 4. Set Content-Type to text/html;charset=UTF-8 in HTTP requests and responses. 5. Pay attention to encoding consistency, conversion and debugging skills to ensure the correct processing of data.

Linux system restricts user resources through the ulimit command to prevent excessive use of resources. 1.ulimit is a built-in shell command that can limit the number of file descriptors (-n), memory size (-v), thread count (-u), etc., which are divided into soft limit (current effective value) and hard limit (maximum upper limit). 2. Use the ulimit command directly for temporary modification, such as ulimit-n2048, but it is only valid for the current session. 3. For permanent effect, you need to modify /etc/security/limits.conf and PAM configuration files, and add sessionrequiredpam_limits.so. 4. The systemd service needs to set Lim in the unit file

The reasons and solutions for the MySQL service cannot be started include: 1. Check the error log and find key error information, such as the port is occupied, and terminate the occupied process through the netstat-ano command. 2. Fix or replace corrupt configuration files, using default configuration or official examples. 3. Ensure that the service is running as a user with sufficient permissions and modify the service login account. 4. Consider upgrading or downgrading the MySQL version, and install the latest stable version after backing up the data. 5. Check the firewall settings to ensure that the MySQL port is allowed to pass. 6. Check the system update log and deal with compatibility issues with dependency libraries or system components. 7. Ensure sufficient hard disk space and avoid insufficient data directory space. 8. If all the above methods are ineffective, seek professional help, such as M

If the iPhone cannot be turned on, you can solve the following methods: 1. Forced restart: For iPhone 8 and later models, quickly press and release the volume up key, then quickly press and release the volume down key, and finally press and hold the side button until you see the Apple logo. 2. Check the battery level: Connect the phone to the charger for at least 15 minutes, and then try to turn it on. 3. Contact Apple customer service or go to Apple's authorized service center for repairs. 4. Use recovery mode: Connect your computer, use iTunes or Finder, press and hold the side button until the logo connected to iTunes appears, and select "Recover". 5. Check for physical damage: Check for cracks, depressions or other damage to the phone. If so, it is recommended to go to the maintenance center for treatment as soon as possible.

To solve the problem that the app cannot be installed after the iOS system is updated, you can use the following steps: 1. Clean the system cache: Go to "Settings" > "General" > "IPhone Storage", uninstall infrequently used apps and restart the device. 2. Solve through downgrade: Download the previous version of iOS firmware and use iTunes or Finder to downgrade. 3. Contact Apple customer service: provide serial number, seek professional help and backup data.

The reason why the editor crashes after the VSCode plugin is updated is that there is compatibility issues with the plugin with existing versions of VSCode or other plugins. Solutions include: 1. Disable the plug-in to troubleshoot problems one by one; 2. Downgrade the problem plug-in to the previous version; 3. Find alternative plug-ins; 4. Keep VSCode and plug-in updated and conduct sufficient testing; 5. Set up automatic backup function to prevent data loss.

Middleware is a filtering mechanism in Laravel that is used to intercept and process HTTP requests. Use steps: 1. Create middleware: Use the command "phpartisanmake:middlewareCheckRole". 2. Define processing logic: Write specific logic in the generated file. 3. Register middleware: Add middleware in Kernel.php. 4. Use middleware: Apply middleware in routing definition.

The latest online login portal for Ouyi OKX Exchange is www.okx.com. Access method: 1. Open the browser; 2. Enter the URL www.okx.com; 3. Click the "Login" button in the upper right corner of the page to enter the login page.
