uniapp vue2 车牌号输入组件记录

2024-01-05 16:44

本文主要是介绍uniapp vue2 车牌号输入组件记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

uniapp vue2 车牌号输入案例记录

组件如图
在这里插入图片描述

直接上代码

1.html

<template><view><view class="plate" :class="{'show': show}"><view class="itemFirst flex-d"><view class="item item1" @click="handleChange(0)">{{ plateNumber[0] || '京' }}</view><view class="item item1" @click="handleChange(1)">{{ plateNumber[1] }}</view></view><view class="point"></view><view class="item" :class="{'active': index === 2}" @click="handleChange(2)">{{ plateNumber[2] }}</view><view class="item" :class="{'active': index === 3}" @click="handleChange(3)">{{ plateNumber[3] }}</view><view class="item" :class="{'active': index === 4}" @click="handleChange(4)">{{ plateNumber[4] }}</view><view class="item" :class="{'active': index === 5}" @click="handleChange(5)">{{ plateNumber[5] }}</view><view class="item" :class="{'active': index === 6}" @click="handleChange(6)">{{ plateNumber[6] }}</view><view class="item new-energy" :class="{'active': index === 7}" @click="handleChange(7)"><view class="newDot flex-c">新能源</view><view class="" v-if="plateNumber[7]"><text>{{ plateNumber[7] }}</text></view></view></view><section class="panel" :class="{'show': show}"><view class="header"><view @click="handleReset">重置</view><view @click="show = false">完成</view></view><view class="panelList"><view class="item" v-for="(item, idx) of currentDatas" :key="idx"><view :class="{'disabled': (index == 1 && idx < 10) || (index > 1 && index < 6 && idx > 33) }" v-if="item !==''" @click="handleClickKeyBoard(item, idx)">{{ item }}</view></view><view class="item backspace" :class="{'special': index === 0 }" @click="handleDelete">×</view></view></section></view>
</template>

2.js

<script>export default {name: "plate",props: {number: {type: Array,default: []}},watch: {number(newVal, oldVal) {this.plateNumber = newVal}},data() {return {show: false,plateNumber: this.number,index: -1,areaDatas: ['京', '津', '渝', '沪', '冀', '晋', '辽', '吉', '黑', '苏','浙', '皖', '闽', '赣', '鲁', '豫', '鄂', '湘', '粤', '琼','川', '贵', '云', '陕', '甘', '青', '蒙', '桂', '宁', '新','藏', '使', '领', '', '', '', '', '', ''],characterDatas: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K','L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V','W', 'X', 'Y', 'Z', '挂', '警', '学', '港', '澳',]}},computed: {currentDatas() {return this.index === 0 ? this.areaDatas : this.characterDatas;},},methods: {handleChange(index) {this.index = index;this.show = true;},handleClickKeyBoard(item, idx) {if ((this.index === 1 && idx < 10) || (this.index > 1 && this.index < 6 && idx > 33)) {return;}if (this.index < 8) {this.$set(this.plateNumber, this.index, item);this.$emit("myPlateChange", this.plateNumber);}if (this.index < 7) {this.index++;}},// 重置handleReset() {this.index = 0;for (let i = 0; i < 8; i++) {this.$set(this.plateNumber, i, '');}this.$emit("myPlateChange", this.plateNumber);},// 删除handleDelete() {this.$set(this.plateNumber, this.index, '');this.$emit("myPlateChange", this.plateNumber);if (this.index > 0) {this.index--;}}}}
</script>

3.css

<style scoped lang='scss'>.new-energy {box-sizing: border-box;border: 2rpx dashed #03BE9F;font-weight: bold;height: 84rpx;background: red;width: 100%;position: relative;.newDot {width: 55rpx;height: 30rpx;border-radius: 50rpx;background: #03BE9F;font-size: 16rpx;color: #fff;position: absolute;top: -20rpx;left: 7rpx;}}.plate {display: flex;justify-content: space-between;.item {width: 70rpx;height: 84rpx;background-color: #F3F4F7;border-radius: 8rpx;text-align: center;line-height: 84rpx;font-size: 32rpx;color: rgba(0, 0, 0, 0.90);font-weight: bold;position: relative;/* margin 18rpx 0 .active {background-color: #bbbbbb;} */}.itemFirst {border-radius: 8rpx;padding: 18rpx 0;height: 84rpx;box-sizing: border-box;background-color: #F3F4F7;.item1 {height: 48rpx;line-height: 48rpx;border-radius: 0;}.item:nth-child(1) {border-right: 2rpx solid #DFDFDF;}}.emptyNew {height: 54px;line-height: 30rpx;text {color: #03BE9F;font-size: 18rpx;}}.point {height: 80rpx;text-align: center;line-height: 80rpx;color: #BDC4CC;font-size: 18rpx;}.triangle {width: 0;height: 0;border: 6rpx solid transparent;border-right-color: #00C69D;border-bottom-color: #00C69D;border-radius: 1rpx 2rpx 1rpx;position: absolute;right: 6rpx;bottom: 6rpx;}}.panel {position: fixed;left: 0;width: 100%;bottom: 0;z-index: 999;box-sizing: border-box;background-color: #F5F5F5;transition: all 0.3s ease;transform: translateY(100%);&.show {transform: translateX(0);}.header {display: flex;align-items: center;justify-content: space-between;padding: 0 24rpx;height: 96rpx;color: #2080F7;font-size: 34rpx;}.panelList {padding: 0 19rpx 20rpx;.item {display: inline-block;width: 80rpx;height: 84rpx;margin-right: 8rpx;margin-bottom: 8rpx;vertical-align: top;border-radius: 8rpx;view {width: 100%;height: 84rpx;line-height: 84rpx;border-radius: 6rpx;background: #FEFFFE;font-size: 32rpx;color: rgba(0, 0, 0, 0.90);font-weight: bold;text-align: center;&.disabled {background-color: rgba(254, 255, 254, 0.6);color: rgba(0, 0, 0, 0.23);}}:nth-of-type(10n) {margin-right: 0;}}.backspace {vertical-align: top;font-size: 48rpx;font-weight: bold;text-align: center;height: 84rpx;line-height: 84rpx;border-radius: 6rpx;background: #FEFFFE;color: rgba(0, 0, 0, 0.90);}}}
</style>

这篇关于uniapp vue2 车牌号输入组件记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/573498

相关文章

Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案

《Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案》:本文主要介绍Vue3组件中getCurrentInstance()获取App实例,但是返回nu... 目录vue3组件中getCurrentInstajavascriptnce()获取App实例,但是返回n

在Spring Boot中浅尝内存泄漏的实战记录

《在SpringBoot中浅尝内存泄漏的实战记录》本文给大家分享在SpringBoot中浅尝内存泄漏的实战记录,结合实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录使用静态集合持有对象引用,阻止GC回收关键点:可执行代码:验证:1,运行程序(启动时添加JVM参数限制堆大小):2,访问 htt

JS+HTML实现在线图片水印添加工具

《JS+HTML实现在线图片水印添加工具》在社交媒体和内容创作日益频繁的今天,如何保护原创内容、展示品牌身份成了一个不得不面对的问题,本文将实现一个完全基于HTML+CSS构建的现代化图片水印在线工具... 目录概述功能亮点使用方法技术解析延伸思考运行效果项目源码下载总结概述在社交媒体和内容创作日益频繁的

前端CSS Grid 布局示例详解

《前端CSSGrid布局示例详解》CSSGrid是一种二维布局系统,可以同时控制行和列,相比Flex(一维布局),更适合用在整体页面布局或复杂模块结构中,:本文主要介绍前端CSSGri... 目录css Grid 布局详解(通俗易懂版)一、概述二、基础概念三、创建 Grid 容器四、定义网格行和列五、设置行

前端下载文件时如何后端返回的文件流一些常见方法

《前端下载文件时如何后端返回的文件流一些常见方法》:本文主要介绍前端下载文件时如何后端返回的文件流一些常见方法,包括使用Blob和URL.createObjectURL创建下载链接,以及处理带有C... 目录1. 使用 Blob 和 URL.createObjectURL 创建下载链接例子:使用 Blob

Vuex Actions多参数传递的解决方案

《VuexActions多参数传递的解决方案》在Vuex中,actions的设计默认只支持单个参数传递,这有时会限制我们的使用场景,下面我将详细介绍几种处理多参数传递的解决方案,从基础到高级,... 目录一、对象封装法(推荐)二、参数解构法三、柯里化函数法四、Payload 工厂函数五、TypeScript

MySQL 中查询 VARCHAR 类型 JSON 数据的问题记录

《MySQL中查询VARCHAR类型JSON数据的问题记录》在数据库设计中,有时我们会将JSON数据存储在VARCHAR或TEXT类型字段中,本文将详细介绍如何在MySQL中有效查询存储为V... 目录一、问题背景二、mysql jsON 函数2.1 常用 JSON 函数三、查询示例3.1 基本查询3.2

SpringQuartz定时任务核心组件JobDetail与Trigger配置

《SpringQuartz定时任务核心组件JobDetail与Trigger配置》Spring框架与Quartz调度器的集成提供了强大而灵活的定时任务解决方案,本文主要介绍了SpringQuartz定... 目录引言一、Spring Quartz基础架构1.1 核心组件概述1.2 Spring集成优势二、J

Vue3使用router,params传参为空问题

《Vue3使用router,params传参为空问题》:本文主要介绍Vue3使用router,params传参为空问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录vue3使用China编程router,params传参为空1.使用query方式传参2.使用 Histo

使用Python实现一键隐藏屏幕并锁定输入

《使用Python实现一键隐藏屏幕并锁定输入》本文主要介绍了使用Python编写一个一键隐藏屏幕并锁定输入的黑科技程序,能够在指定热键触发后立即遮挡屏幕,并禁止一切键盘鼠标输入,这样就再也不用担心自己... 目录1. 概述2. 功能亮点3.代码实现4.使用方法5. 展示效果6. 代码优化与拓展7. 总结1.