Table of Contents
Vue3 Vant password input box custom display/hide password icon
Home Web Front-end JS Tutorial Why does the eye icon disappear when using the password input box of the vant frame? How to solve it?

Why does the eye icon disappear when using the password input box of the vant frame? How to solve it?

Apr 04, 2025 pm 04:09 PM
css vue Browser Solution Why

Why does the eye icon disappear when using the password input box of the vant frame? How to solve it?

Vue3 Vant password input box custom display/hide password icon

When developing with Vue3 and Vant frameworks, you may encounter problems with missing or abnormal display of the Vant password input box with its own password display/hide function. This is usually caused by the browser's default password input box style conflicts with the Vant component style. The solution is to customize the password display/hide function and hide the browser's default icon.

Problem Description: The Vant password input box displays the password display/hide icon (browser default icon) when the first focus is focused, but after losing focus, the icon disappears.

Workaround: Use CSS to hide the browser default icon and use v-model provided by Vant and custom logic to control the display/hide of passwords.

CSS code (hide browser default icon):

 input[type="password"]::-webkit-toggle-password { /*chrome*/
  -webkit-appearance: none!important;
  display: none!important;
}
input[type="password"]::-moz-ui-password { /*firefox*/
  -moz-appearance: none!important;
  display: none!important;
}
input[type="password"]::-ms-reveal { /*edge*/
  display: none!important;
}
Copy after login

Vue component code (example, need to be adjusted according to actual situation):

<template>
  <div>
    <input type="password" v-model="password" :type="showPassword ? 'text' : 'password'">
    <van-icon name="eye"></van-icon>
  </div>
</template>

<script>
import { ref } from 'vue';
import { Icon } from 'vant';

export default {
  components: {
    [Icon.name]: Icon,
  },
  setup() {
    const password = ref('');
    const showPassword = ref(false);
    return { password, showPassword };
  },
};
</script>
Copy after login

This code uses Vant's van-icon component to create a custom password display/hide icon, and dynamically controls type attribute of the input box through v-model and showPassword variables to realize the display and hiding of the password. Remember to add the above CSS code to your project stylesheet. This solution avoids conflicts with the browser's default style and provides a more consistent user experience.

The above is the detailed content of Why does the eye icon disappear when using the password input box of the vant frame? How to solve it?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to write oracle database statements How to write oracle database statements Apr 11, 2025 pm 02:42 PM

The core of Oracle SQL statements is SELECT, INSERT, UPDATE and DELETE, as well as the flexible application of various clauses. It is crucial to understand the execution mechanism behind the statement, such as index optimization. Advanced usages include subqueries, connection queries, analysis functions, and PL/SQL. Common errors include syntax errors, performance issues, and data consistency issues. Performance optimization best practices involve using appropriate indexes, avoiding SELECT *, optimizing WHERE clauses, and using bound variables. Mastering Oracle SQL requires practice, including code writing, debugging, thinking and understanding the underlying mechanisms.

How to interpret warnings in Tomcat logs How to interpret warnings in Tomcat logs Apr 12, 2025 pm 11:45 PM

Warning messages in the Tomcat server logs indicate potential problems that may affect application performance or stability. To effectively interpret these warning information, you need to pay attention to the following key points: Warning content: Carefully study the warning information to clarify the type, cause and possible solutions. Warning information usually provides a detailed description. Log level: Tomcat logs contain different levels of information, such as INFO, WARN, ERROR, etc. "WARN" level warnings are non-fatal issues, but they need attention. Timestamp: Record the time when the warning occurs so as to trace the time point when the problem occurs and analyze its relationship with a specific event or operation. Context information: view the log content before and after warning information, obtain

React, Vue, and the Future of Netflix's Frontend React, Vue, and the Future of Netflix's Frontend Apr 12, 2025 am 12:12 AM

Netflix mainly uses React as the front-end framework, supplemented by Vue for specific functions. 1) React's componentization and virtual DOM improve the performance and development efficiency of Netflix applications. 2) Vue is used in Netflix's internal tools and small projects, and its flexibility and ease of use are key.

What is apache server? What is apache server for? What is apache server? What is apache server for? Apr 13, 2025 am 11:57 AM

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

How to configure HTTPS server in Debian OpenSSL How to configure HTTPS server in Debian OpenSSL Apr 13, 2025 am 11:03 AM

Configuring an HTTPS server on a Debian system involves several steps, including installing the necessary software, generating an SSL certificate, and configuring a web server (such as Apache or Nginx) to use an SSL certificate. Here is a basic guide, assuming you are using an ApacheWeb server. 1. Install the necessary software First, make sure your system is up to date and install Apache and OpenSSL: sudoaptupdatesudoaptupgradesudoaptinsta

mongodb command line connection mongodb command line connection method mongodb command line connection mongodb command line connection method Apr 12, 2025 am 07:00 AM

This article introduces the MongoDB command line connection method. 1. Use the mongo command to connect to the local instance; 2. Use the --host and --port parameters to connect to the instances with the specified address and port; 3. Use the -u and -p parameters to authenticate the username and password; 4. Use the connection string mongodb://&lt;username&gt;:&lt;password&gt;@&lt;hostname&gt;:&lt;port&gt;/&lt;database&gt; to simplify the connection, but pay attention to password security.

What aspects should be investigated for disaster recovery of oracle database What aspects should be investigated for disaster recovery of oracle database Apr 11, 2025 pm 03:21 PM

The selection of Oracle database disaster recovery plan depends on business needs, and the key indicators are RTO (recovery time target) and RPO (recovery point target). Depending on RTO and RPO, you can choose hot backup (high availability, low data loss), warm backup (moderate cost, long recovery time) or cold backup (low cost, big data loss). Specific technical solutions include RMAN (backup and recovery tool), Data Guard (high availability solution), and GoldenGate (change data capture and copy tool). Frequently asked questions include network issues, storage issues, and configuration errors that can be resolved through monitoring, optimization, and periodic testing. Remember that disaster recovery is a process of continuous maintenance and optimization, and improving documents is conducive to rapid recovery of the database.

See all articles