Vue3

【vant3】在 vue3 中实现密码框的显示隐藏

2021-11-23  本文已影响0人  睡神疯子

html 部分

<van-field
  v-model="loginPassword"
  :type="switchPassType ? 'text' : 'password'"
  name="loginPassword"
  :right-icon="switchPassType ? 'eye' : 'closed-eye'"
  placeholder="登录密码"
  :rules="[{ required: true, message: '请填写登录密码' }]"
  @click-right-icon="switchPassType = !switchPassType"
/>

js 部分

import { Field } from "vant";
import { ref } from "vue";
export default {
  name: "login",
  components: {
    [Field.name]: Field,
  },
  setup() {
    const loginPassword = ref('');
    const switchPassType = ref(false);
    return {
      loginPassword,
      switchPassType,
    };
  },
};
上一篇 下一篇

猜你喜欢

热点阅读