Find informationSome methods found on the Internet:
Implementation process Fields used data() { return { username: '', password: '', } } Since modern browsers no longer support autocomplete="off", we simply gave up setting the password box and used autocomplete="new-password" directly. We have tested that it works in Chrome (v88.0.4324.104), Edge (v88.0.705.56) and Firefox (v67), but Firefox (v85) will still prompt us to remember the password. <el-input v-model="username" type="text" name="text" placeholder="account" autocomplete="off"><i slot="prefix" class="el-input_icon el-icon-user"></i></el-input> <el-input v-model="password" type="password" name="pwd" id="pwd" placeholder="password" autocomplete="new-password"></el-input> refer to: https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#browser_compatibility In the process of solving the prompt of high version of Firefox, I tried methods 3/4/5, but the results were not satisfactory. However, I found that as long as the value in the final password box of Firefox is an asterisk "*" or a small dot "●", it will not prompt to remember the password (I don’t know if it is correct, you can test it yourself), so I added a new field pwdCover to associate the input box, and use password to actually pass the value. templete <el-input v-model="username" type="text" name="text" placeholder="account" autocomplete="off"><i slot="prefix" class="el-input_icon el-icon-user"></i></el-input> <el-input v-model="pwdCover" type="password" name="pwd" id="pwd" placeholder="password" autocomplete="new-password"@input="setPassword"></el-input> script data() { return { username: '', password: '', pwdCover: '', } }, method: login() { this.pwdCover = this.pwdCover.replace(/\S/g, '●'); // Login request, restore pwdCover if failed this.pwdCover = this.password; }, setPassword(val) { this.password = val; } } I sent it to my colleagues on the project with full confidence, but it turned out to be a failure. The on-site environment was as follows:
After I installed the same version of Google Chrome, I found that the problem still did not occur. My operating system is Windows 10. I don’t know what went wrong. In the end, I chose method 6. final templete <el-form-item> <el-input v-model="username" type="text" name="text" placeholder="account" autocomplete="off"><i slot="prefix" class="el-input_icon el-icon-user"></i></el-input> </el-form-item> <el-form-item> <el-input v-model="pwdCover" type="text" name="pwd" id="pwd" placeholder="Password" autocomplete="off" @input="setPassword"><i slot="prefix" class="el-icon-lock"></i></el-input> </el-form-item> script setPassword(val) { let reg = /[0-9a-zA-Z]/g; // Only letters and numbers are allowedlet nDot = /[^●]/g; // Non-dot characterslet index = -1; // Newly entered character positionlet lastChar = void 0; // Newly entered characterlet realArr = this.password.split(''); // Real password arraylet coverArr = val.split(''); // Text box displays password arraylet coverLen = val.length; // Text box string lengthlet realLen = this.password.length; // Real password length// Find the newly entered characters and positionscoverArr.forEach((el, idx) => { if(nDot.test(el)) { index = idx; lastChar = el; } }); // Check if the input character meets the specification. If not, remove the character if(lastChar && !reg.test(lastChar)) { coverArr.splice(index, 1); this.pwdCover = coverArr.join(''); return; } if (realLen < coverLen) { // Add new characters realArr.splice(index, 0, lastChar); } else if (coverLen <= realLen && index !== -1) { // Replace characters (select one or more characters to replace directly) realArr.splice(index, realLen - (coverLen - 1), lastChar); } else { // Delete characters. Because val is all ●, there is no way to match. I don't know whether the characters are deleted from the end or the middle. It is difficult to handle password after deleting several characters. So we can judge by the cursor position and the length of val. let pos = document.getElementById('pwd').selectionEnd; // Get the cursor position realArr.splice(pos, realLen - coverLen); } // Replace pwdCover with this.pwdCover = val.replace(/\S/g, '●'); this.password = realArr.join(''); }, This is the end of this article about the sample code for Vue to implement the function of prohibiting browsers from remembering passwords. For more relevant content about Vue prohibiting browsers from remembering passwords, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A brief talk about MySQL semi-synchronous replication
>>: An enhanced screenshot and sharing tool for Linux: ScreenCloud
What is a table? It is composed of cell cells. In...
Find the problem After upgrading MySQL to MySQL 5...
Problem Description In the recent background serv...
Table of contents Phenomenon Root Cause Analysis ...
This article example shares the application code ...
Installation Environment WIN10 VMware Workstation...
Table of contents 1. Connection Management 2. Imp...
1. Apache static resource cross-domain access Fin...
Preface There are many open source monitoring too...
1. Download the image docker pull selenium/hub do...
Table of contents 1. Character Function 1. Case c...
As users become more privacy-conscious and take m...
Error description When we install Docker Desktop,...
Moreover, an article website built with a blog pro...
Just as the title! The commonly used font-family l...