특정 요구 사항: 고객 정보 양식의 작업 열에서 결제 비밀번호 수정 버튼을 클릭하면 6자리 결제 비밀번호 입력 상자 구성 요소 페이지로 이동합니다. 동시에 입력 상자는 암호문을 표시해야 하며 편집할 수 없고 되돌릴 수 없으며 즉시 표시됩니다. 6자리에 도달하면 결제 비밀번호 확인 시 자동으로 입력됩니다. 6자리에 도달하면 입력한 두 비밀번호의 일치 여부를 자동으로 확인하고 확인 버튼이 표시됩니다. 이 기능은 고객이 장치를 사용하여 비밀번호를 입력하는 은행에서 사용하기 위한 것입니다. 하지만 창구 직원은 비밀번호를 입력할 수 있습니다.
구체적인 질문: 1. 암호 텍스트를 표시하는 방법, 각 상자에 1자리만 입력할 수 있음 2. 입력란을 편집 및 되돌릴 수 없도록 만드는 방법 3. 일관성을 확인하는 방법; 비밀번호를 두 번 입력했습니다. 4. 회사에서 키보드 키를 제한해야 하는 경우 어떻게 해야 합니까?
1. 코드 개요
6자리 결제 비밀번호 입력란 컴포넌트를 구현하는 코드는 다음과 같습니다. 복사해서 바로 사용해보세요!
<template> <div > <!-- 密码输入框 --> <div class="input-box" > <!-- 输入密码 --> <div >{{ "输入密码" }}</div> <div class="input-content" @keyup="keyup" @input="inputEvent"> <input max="9" min="0" maxlength="1" data-index="0" v-model.number="state.input[0]" type="password" ref="firstinput" :disabled="state.disabledInput[0]" /> <input max="9" min="0" maxlength="1" data-index="1" v-model.number="state.input[1]" type="password" :disabled="state.disabledInput[1]" /> <input max="9" min="0" maxlength="1" data-index="2" v-model.number="state.input[2]" type="password" :disabled="state.disabledInput[2]" /> <input max="9" min="0" maxlength="1" data-index="3" v-model.number="state.input[3]" type="password" :disabled="state.disabledInput[3]" /> <input max="9" min="0" maxlength="1" data-index="4" v-model.number="state.input[4]" type="password" :disabled="state.disabledInput[4]" /> <input max="9" min="0" maxlength="1" data-index="5" v-model.number="state.input[5]" type="password" :disabled="state.disabledInput[5]" /> </div> <!-- 确认密码 --> <div >{{ "确认密码" }}</div> <div class="input-content" @keyup="confirmKeyUp" @input="confirmInputEvent"> <input max="9" min="0" maxlength="1" data-index="0" v-model.number="state.confirmInput[0]" type="password" ref="confirmfirstinput" :disabled="state.disabledConfirmInput[0]" /> <input max="9" min="0" maxlength="1" data-index="1" v-model.number="state.confirmInput[1]" type="password" :disabled="state.disabledConfirmInput[1]" /> <input max="9" min="0" maxlength="1" data-index="2" v-model.number="state.confirmInput[2]" type="password" :disabled="state.disabledConfirmInput[2]" /> <input max="9" min="0" maxlength="1" data-index="3" v-model.number="state.confirmInput[3]" type="password" :disabled="state.disabledConfirmInput[3]" /> <input max="9" min="0" maxlength="1" data-index="4" v-model.number="state.confirmInput[4]" type="password" :disabled="state.disabledConfirmInput[4]" /> <input max="9" min="0" maxlength="1" data-index="5" v-model.number="state.confirmInput[5]" type="password" :disabled="state.disabledConfirmInput[5]" /> </div> </div> <!-- 按钮 --> <div > <el-button type="info" :disabled="state.disabledConfirm" @click="reConfirm" :class="[state.disabledConfirm ? 'noActive' : 'active']">{{ "确定" }}</el-button> <el-button type="warning" @click="reset">{{ "重新输入" }}</el-button> </div> <!-- 提示区 --> <div > <p>{{ state.tipContent }}</p> </div> </div> </template> <script lang="ts" setup> import { nextTick, reactive, ref, onMounted } from "vue"; import { ElMessage, ElMessageBox } from 'element-plus' const state = reactive({ // 输入数组 input: ["", "", "", "", "", ""], // 确认输入数组 confirmInput: ["", "", "", "", "", ""], // 存放粘贴进来的数字 pasteResult: [], confirmPasteResult: [], // 一上来禁用确定按钮 disabledConfirm: true, // 输入框是否禁用 disabledInput: [false, false, false, false, false, false], disabledConfirmInput: [false, false, false, false, false, false], // 提示内容 tipContent: "请告知客户输入6位数字密码,输入完毕后,点击回车确认。" }) // 获取第一个元素的ref const firstinput = ref() const confirmfirstinput = ref() // 页面一加载就使第一个框聚焦 onMounted(() => { // 等待dom渲染完成,在执行focus,否则无法获取到焦点 nextTick(() => { firstinput.value.focus(); }); }) // @input的处理方法 // 解决一个输入框输入多个字符 const inputEvent = (e) => { var index = e.target.dataset.index * 1; var el = e.target; // 限制只能输入数字 el.value = el.value.replace(/[^\d]/g, ""); if (el.value.length >= 1) { // 密文显示、不可编辑、不可回退、即时显示 state.disabledInput[index] = true; if (el.nextElementSibling) { el.nextElementSibling.focus(); } } // 到达6位数,自动进入确认支付密码 if (!el.nextElementSibling) { confirmfirstinput.value.focus(); state.tipContent = "请告知客户再次输入6位数字密码,输入完毕后,点击回车确认。"; } } // @keydown的处理方法,根据业务需要添加 // 此示例没有使用 const keydown = (e) => { var index = e.target.dataset.index * 1; var el = e.target; // 回退键 if (e.key === 'Backspace') { if (state.input[index].length > 0) { state.input[index] = '' } else { if (el.previousElementSibling) { el.previousElementSibling.focus() state.input[index - 1] = '' } } } // 删除键 else if (e.key === 'Delete') { if (state.input[index].length > 0) { state.input[index] = '' } else { if (el.nextElementSibling) { state.input[1] = '' } } if (el.nextElementSibling) { el.nextElementSibling.focus() } } // 左键 else if (e.key === 'ArrowLeft') { if (el.previousElementSibling) { el.previousElementSibling.focus() } } // 右键 else if (e.key === 'ArrowRight') { if (el.nextElementSibling) { el.nextElementSibling.focus() } } // 上键 else if (e.key === 'ArrowUp') { if (Number(state.input[index]) * 1 < 9) { state.input[index] = (Number(state.input[index]) * 1 + 1).toString() } } // 下键 else if (e.key === 'ArrowDown') { if (Number(state.input[index]) * 1 > 0) { state.input[index] = (Number(state.input[index]) * 1 - 1).toString() } } } // @keyup的处理方法 const keyup = (e) => { var index = e.target.dataset.index * 1; // 如果为最后一个框,则输入框全部失焦 if (index === 5) { if (state.input.join("").length === 6) { document.activeElement.blur(); } } } // @input的处理方法 // 解决一个输入框输入多个字符 const confirmInputEvent = (e) => { var index = e.target.dataset.index * 1; var el = e.target; if (el.value.length >= 1) { // 密文显示、不可编辑、不可回退、即时显示 state.disabledConfirmInput[index] = true; if (el.nextElementSibling) { el.nextElementSibling.focus(); } } // 到达6位数,自动检验两次输入密码的一致性 if (!el.nextElementSibling) { // 一一比较元素值,有一个不相等就不等 for (let i = 0; i < state.input.length; i++) { if (state.input[i] !== state.confirmInput[i]) { state.tipContent = "请告知客户两次密码输入不一致,柜员点击重新输入,清空密码后请告知客户重新输入。"; return; } } state.tipContent = "密码合规,点击确定按钮进行修改。"; // 确定按钮变为可用 state.disabledConfirm = false; } } // @keydown的处理方法,根据业务需要添加 // 此示例没有使用 const confirmKeydown = (e) => { var index = e.target.dataset.index * 1; var el = e.target; // 回退键 if (e.key === 'Backspace') { if (state.confirmInput[index].length > 0) { state.confirmInput[index] = '' } else { if (el.previousElementSibling) { el.previousElementSibling.focus() state.confirmInput[index - 1] = '' } } } // 删除键 else if (e.key === 'Delete') { if (state.confirmInput[index].length > 0) { state.confirmInput[index] = '' } else { if (el.nextElementSibling) { state.confirmInput[1] = '' } } if (el.nextElementSibling) { el.nextElementSibling.focus() } } // 左键 else if (e.key === 'ArrowLeft') { if (el.previousElementSibling) { el.previousElementSibling.focus() } } // 右键 else if (e.key === 'ArrowRight') { if (el.nextElementSibling) { el.nextElementSibling.focus() } } // 上键 else if (e.key === 'ArrowUp') { if (Number(state.confirmInput[index]) * 1 < 9) { state.confirmInput[index] = (Number(state.confirmInput[index]) * 1 + 1).toString() } } // 下键 else if (e.key === 'ArrowDown') { if (Number(state.confirmInput[index]) * 1 > 0) { state.confirmInput[index] = (Number(state.confirmInput[index]) * 1 - 1).toString() } } } // @keyup的处理方法 const confirmKeyUp = (e) => { var index = e.target.dataset.index * 1; // 如果为最后一个框,则输入框全部失焦 if (index === 5) { if (state.confirmInput.join("").length === 6) { document.activeElement.blur(); } } } // 重新输入 const reset = () => { state.disabledConfirm = true; state.tipContent = "请告知客户输入6位数字密码,输入完毕后,点击回车确认。"; state.input = ["", "", "", "", "", ""]; state.confirmInput = ["", "", "", "", "", ""]; state.disabledInput = [false, false, false, false, false, false]; state.disabledConfirmInput = [false, false, false, false, false, false]; // 等待dom渲染完成,在执行focus,否则无法获取到焦点 nextTick(() => { firstinput.value.focus(); }); } // 确认修改 const reConfirm = () => { ElMessageBox.confirm( '是否确定修改?', '温馨提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', } ) .then(() => { // 此处调修改支付密码接口 ElMessage({ type: 'success', message: '修改成功!', }) }) .catch(() => { ElMessage({ type: 'info', message: '已取消修改!', }) }) } </script> <style lang="scss" scoped> .input-box { .input-content { width: 512px; height: 60px; display: flex; align-items: center; justify-content: space-between; input { color: inherit; font-family: inherit; border: 0; outline: 0; border-bottom: 1px solid #919191; height: 60px; width: 60px; font-size: 44px; text-align: center; } } input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { appearance: none; margin: 0; } } .noActive { color: #fff !important; border-width: 0px !important; background-color: #ccc !important; } .active { color: #fff !important; border-width: 0px !important; background-color: #67c23a !important; } </style>
2. 문제 분석
1. 질문: 암호문을 표시하는 방법과 각 상자에 1자리만 입력할 수 있나요?
비밀번호를 입력하려면 입력창 유형을 "비밀번호"로 설정하기만 하면 됩니다. 각 상자에 1자리만 입력할 수 있다는 점을 이해하려면 입력 상자의 maxlength 속성만 사용하는 효과가 완벽하지 않으며 제한할 수 없는 상황이 있을 수 있습니다. @input 이벤트입니다. 1보다 크면 nextElementSibling.focus()를 사용하여 다음 형제 요소에 커서를 놓습니다.
2. 질문: 입력 상자를 편집할 수 없고 반환할 수 없게 만드는 방법은 무엇입니까?
답변: @input 이벤트에서는 입력 상자의 비활성화 속성을 사용하며, 현재 입력 요소의 비활성화 속성을 true로 변경할 수 있습니다. 후속 획득 및 수정을 용이하게 하기 위해 입력 상자의 비활성화된 속성 값을 배열에 저장합니다.
3. 질문: 두 번 입력한 비밀번호의 일관성을 확인하는 방법은 무엇인가요?
답변: 가장 간단한 for 루프는 입력 비밀번호 배열과 확인 비밀번호 배열을 순회하고 해당 요소 값을 하나씩 비교하여 동일하지 않으면 동일하지 않으며 전체 함수의 실행을 종료하는 데 사용됩니다. 반품을 통해;.
4. 질문: 회사에서 키보드 키를 제한해야 하는 경우 어떻게 해야 합니까?
답변: @keydown 또는 @keyup 이벤트를 입력 상자에 추가하고 콜백 내부의 키를 판단하여 다양한 키에 대해 일부 비즈니스 처리를 수행할 수 있습니다.
위 내용은 vue3에서 6자리 결제 비밀번호 입력란을 구현하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Netflix는 React를 프론트 엔드 프레임 워크로 사용합니다. 1) React의 구성 요소화 된 개발 모델과 강력한 생태계가 Netflix가 선택한 주된 이유입니다. 2) 구성 요소화를 통해 Netflix는 복잡한 인터페이스를 비디오 플레이어, 권장 목록 및 사용자 댓글과 같은 관리 가능한 청크로 분할합니다. 3) React의 가상 DOM 및 구성 요소 수명주기는 렌더링 효율성 및 사용자 상호 작용 관리를 최적화합니다.

프론트 엔드 기술에서 Netflix의 선택은 주로 성능 최적화, 확장 성 및 사용자 경험의 세 가지 측면에 중점을 둡니다. 1. 성능 최적화 : Netflix는 React를 주요 프레임 워크로 선택하고 Speedcurve 및 Boomerang과 같은 도구를 개발하여 사용자 경험을 모니터링하고 최적화했습니다. 2. 확장 성 : 마이크로 프론트 엔드 아키텍처를 채택하여 응용 프로그램을 독립 모듈로 분할하여 개발 효율성 및 시스템 확장 성을 향상시킵니다. 3. 사용자 경험 : Netflix는 재료 -UI 구성 요소 라이브러리를 사용하여 A/B 테스트 및 사용자 피드백을 통해 인터페이스를 지속적으로 최적화하여 일관성과 미학을 보장합니다.

NetflixusesAcustomFrameworkCalled "Gibbon"BuiltonReact, NotreactorVuedirectly.1) TeamExperience : 2) ProjectComplexity : vueforsimplerProjects, 3) CustomizationNeeds : reactoffersmoreflex.4)

Netflix는 주로 프레임 워크 선택의 성능, 확장 성, 개발 효율성, 생태계, 기술 부채 및 유지 보수 비용을 고려합니다. 1. 성능 및 확장 성 : Java 및 SpringBoot는 대규모 데이터 및 높은 동시 요청을 효율적으로 처리하기 위해 선택됩니다. 2. 개발 효율성 및 생태계 : React를 사용하여 프론트 엔드 개발 효율성을 향상시키고 풍부한 생태계를 활용하십시오. 3. 기술 부채 및 유지 보수 비용 : Node.js를 선택하여 유지 보수 비용과 기술 부채를 줄이기 위해 마이크로 서비스를 구축하십시오.

Netflix는 주로 VUE가 특정 기능을 위해 보충하는 프론트 엔드 프레임 워크로 React를 사용합니다. 1) React의 구성 요소화 및 가상 DOM은 Netflix 애플리케이션의 성능 및 개발 효율을 향상시킵니다. 2) VUE는 Netflix의 내부 도구 및 소규모 프로젝트에 사용되며 유연성과 사용 편의성이 핵심입니다.

vue.js는 복잡한 사용자 인터페이스를 구축하는 데 적합한 점진적인 JavaScript 프레임 워크입니다. 1) 핵심 개념에는 반응 형 데이터, 구성 요소화 및 가상 DOM이 포함됩니다. 2) 실제 응용 분야에서는 TODO 응용 프로그램을 구축하고 Vuerouter를 통합하여 시연 할 수 있습니다. 3) 디버깅 할 때 VuedeVtools 및 Console.log를 사용하는 것이 좋습니다. 4) 성능 최적화는 V-IF/V- 쇼, 목록 렌더링 최적화, 구성 요소의 비동기로드 등을 통해 달성 할 수 있습니다.

vue.js는 중소형 프로젝트에 적합하지만 REACT는 크고 복잡한 응용 프로그램에 더 적합합니다. 1. Vue.js의 응답 형 시스템은 종속성 추적을 통해 DOM을 자동으로 업데이트하여 데이터 변경을 쉽게 관리 할 수 있습니다. 2. 반응은 단방향 데이터 흐름을 채택하고 데이터 흐름에서 하위 구성 요소로 데이터가 흐르고 명확한 데이터 흐름과 곤란하기 쉬운 구조를 제공합니다.

vue.js는 중소형 프로젝트 및 빠른 반복에 적합한 반면 React는 크고 복잡한 응용 프로그램에 적합합니다. 1) vue.js는 사용하기 쉽고 팀이 불충분하거나 프로젝트 규모가 작는 상황에 적합합니다. 2) React는 더 풍부한 생태계를 가지고 있으며 고성능 및 복잡한 기능적 요구가있는 프로젝트에 적합합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

Dreamweaver Mac版
시각적 웹 개발 도구

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.
