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>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/600359.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Ubuntu不能挂载移动硬盘

我有一个2T 的移动硬盘&#xff0c;分了两个区 不知道为啥突然之间一个分区老无法挂载&#xff0c;万能的重启也无法解决。 经查资料&#xff0c;这种情况一般是在使用时&#xff08;如看电影或者拷贝文件过程中&#xff09;将移动硬盘异常拔出再插入时&#xff0c;就提示不能…

学习录

概述 这几年在迷茫中看了不少资料&#xff0c;有觉得写得很棒的&#xff0c;也有写的很糟糕的。所以一直想写这块的总结来进行归纳&#xff0c;同时也希望能给其他处于迷茫中的朋友提供一份高质量的资料列表(也许一个读者也没有)&#xff0c;以下清单个人觉得值得反复看以及思…

Redis 教程

Redis 简介 Redis 是完全开源的&#xff0c;遵守 BSD 协议&#xff0c;是一个高性能的 key-value 数据库。 Redis 与其他 key - value 缓存产品有以下三个特点&#xff1a; Redis支持数据的持久化&#xff0c;可以将内存中的数据保存在磁盘中&#xff0c;重启的时候可以再次…

Android低功耗蓝牙开发总结

基础使用 权限申请 蓝牙权限在各个版本中略有不同 Android 12 及以上版本&#xff0c;如果不需要通过蓝牙来推断位置的话&#xff0c;蓝牙扫描不需要开启位置权Android 11 及以下版本&#xff0c;蓝牙扫描必须开启位置权限Android 9 及以下版本&#xff0c;蓝牙扫描可开启粗…

【Turtle库】圣诞树

在寒冷的冬季&#xff0c;没有什么比一棵亮丽的圣诞树更能带给我们温暖和快乐。而现在&#xff0c;我们将使用Python编程语言来绘制这样一棵美丽的圣诞树。 首先&#xff0c;我们需要导入Python的turtle模块&#xff0c;它可以帮助我们绘制图形。然后&#xff0c;我们可以定义一…

《数字图像处理》 第11章 表示和描述 学习笔记附部分例子代码(c++opencv)

表示和描述 0. 前言1. 表示1.1 边界追踪1.2 链码1.3 使用最小周长多边形的多边形近似 2. 边界描绘子2.1 一些简单的描绘子![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/45dddc76217e4fde93a11e2631b2a71a.png#pic_center 500x)2.2 形状数2.3 傅里叶描绘子2.4 统计…

第11章 GUI Page462~476 步骤二十三 步骤二十四 Undo/Redo ①为Undo/Redo做准备工作,弹出日志窗口

step23和step24合起来学习 工程一 1.主窗口类中添加新的私有成员数据&#xff1a; 2 主窗口构造函数中&#xff0c;最后一行加入&#xff0c;用于调试的Log功能 3 鼠标弹起函数&#xff0c;添加Undo动作 4 编译之后报错&#xff1a;ActionLink不是一个类型 5 新增一个头文件…

Fast DDS 官方--C++ API Reference

Fast DDS 官方--C API Reference 1 介绍2 接口2.1 DDS DCPS PIM2.1.1 Core2.1.1.1 Entity 【基类】2.1.1.2 DomainEntity2.1.1.3 Policy 【枚举】2.1.1.3.1 DataRepresentationId2.1.1.3.2 DataRepresentationQosPolicy2.1.1.3.3 DataSharingQosPolicy2.1.1.3.4 DataSharingKin…

nginx连接数和性能优化

目录 一&#xff1a;介绍 二&#xff1a;优化配置 三&#xff1a;其他优化策略 一&#xff1a;介绍 Nginx是一个高性能的HTTP和反向代理服务器&#xff0c;具有许多用于优化连接数和性能的配置选项。以下是一些关键的配置和优化建议&#xff1a; 1&#xff1a;worker_proc…

Spark概述

Spark概述 Spark是什么 Apache Spark是一个快速的&#xff0c;多用途的集群计算系统&#xff0c;相对于Hadoop MapReduce将中间结果保存在磁盘中&#xff0c;Spark使用了内存保存中间结果&#xff0c;能在数据尚未写入硬盘时在内存中进行运算Spark只是一个计算框架&#xff0c;…

Mac Install Parallels Desktop 19.1.0

资料准备 ParallelsDesktop-19.1.0-54729.dmg Parallels Desktop Activation Tool 4.0.0 [MacKed].dmg链接: https://pan.baidu.com/s/1kxUKreiKdJXQIPXAJ8LJsA?pwd6666 提取码: 6666 –来自百度网盘超级会员v7的分享 双击 ParallelsDesktop-19.1.0-54729.dmg 点击打开 …

Apple 移动设备管理常见问题解答

什么是 Apple 移动设备管理 (MDM)&#xff1f; Apple 在企业中的扩张带来了生产力更高的员工队伍以及员工真正在任何地方工作的能力。 但更多的自由、不断扩大的边界和新的操作系统也会带来挑战。 任何规模的组织都必须让每个人的设备保持最佳运行状态&#xff0c;确保硬件和网…

Android studio环境配置

1.搜索android studio下载 Android Studio - Download 2.安装 3.配置环境 配置gradle&#xff0c;gradle参考网络配置。最后根据项目需求选择不同的jdk。

flutter 五:MaterialApp

MaterialApp const MaterialApp({super.key,this.navigatorKey, //导航键this.scaffoldMessengerKey, //scaffold管理this.home, //首页Map<String, WidgetBuilder> this.routes const <String, WidgetBuilder>{}, //路由this.initialRoute, //初始路由th…

Oracle START WITH 递归语句的使用方法及示例

Oracle数据库中的START WITH语句经常与CONNECT BY子句一起使用&#xff0c;以实现对层次型数据的查询。这种查询模式非常适用于处理具有父子关系的数据&#xff0c;如组织结构、分类信息等。 理解START WITH和CONNECT BY 在层次型查询中&#xff0c;START WITH定义了层次结构…

【SpringMVC】常用注解

什么是MVC&#xff1f; MVC是一种程序分层开发模式&#xff0c;分别是Model&#xff08;模型&#xff09;&#xff0c;View&#xff08;视图&#xff09;以及Controller&#xff08;控制器&#xff09;。这样做可以将程序的用户界面和业务逻辑分离&#xff0c;使得代码具有良好…

Leetcode2966. 划分数组并满足最大差限制

Every day a Leetcode 题目来源&#xff1a;2966. 划分数组并满足最大差限制 解法1&#xff1a;排序 将数组 nums 从小到大排序&#xff0c;每三个一组插入答案&#xff0c;如果有 nums[i 2] - nums[i] > k&#xff0c;则不满足要求&#xff0c;返回空数组。 代码&…

专业实习day3、4(路由器做内网访问公网)

专业实习 代码 display ip interface brief 显示当前设备下所有接口IP undo IP地址支持覆盖&#xff0c;但是正常的命令不能覆盖必须undo&#xff08;删除&#xff09;掉 un in en 在做配置的过程中&#xff0c;设备系统一般都会出现一些提示或者告警之类的东西&#xff0c;从…

matplotlib 虚战1

EDA 入门 visualization.py import matplotlib matplotlib.use("TkAgg")import pandas as pd from matplotlib import pyplot as plt import warningswarnings.filterwarnings(ignore)df pd.read_csv("diabetes.csv")# look at the first 5 rows of the…