移动端自定义键盘的vue组件 ----keyboard
<style scoped lang="less">
.keyboard {
/* height: 250px; */
width: 100%;
position: fixed;
bottom: 0;
left: 0;
background: white;
z-index: 999;
.list {
/* height: 200px; */
display: flex;
.key {
font-size: 34px;
box-sizing: border-box;
height: 120px;
width: 33.33%;
float: left;
border-right: 1px solid #d6d6d6;
border-top: 1px solid #d6d6d6;
display: flex;
align-items: center;
justify-content: center;
&.confirm {
height: 360px;
background: #ED5665;
color: white;
font-size: 34px;
}
&.del {
font-weight: 100;
font-size: 64px;
}
&.active{
background-color: #F6F6F6;
}
}
.num {
width: 75%;
.key:nth-child(-n+3) {
border-top: none;
}
}
.tool {
width: 25%;
.key {
width: 100%;
border-right: none;
border-top: none;
}
}
}
}
.animated {
animation-duration: .2s;
animation-fill-mode: both;
}
@keyframes tabDown {
from {
background-color: #ffffff;
}
to {
background-color: #F6F6F6;
}
}
@keyframes tabUp {
from {
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
transform: translate3d(0, 0, 0);
}
}
.slide-enter-active {
animation-name: slideInUp;
}
.slide-leave-active {
animation-name: slideInDown;
}
</style>
<template>
<transition name="slide">
<div class="keyboard animated" v-show="show" @touchstart.stop.prevent="fn">
<!-- 完成 按钮-->
<!-- 键盘区域 -->
<div class="list">
<div class="num">
<div :class="['key', {active:active[1]}]" @touchstart="typing('1')">1</div>
<div :class="['key', {active:active[2]}]" @touchstart="typing('2')">2</div>
<div :class="['key', {active:active[3]}]" @touchstart="typing('3')">3</div>
<div :class="['key', {active:active[4]}]" @touchstart="typing('4')">4</div>
<div :class="['key', {active:active[5]}]" @touchstart="typing('5')">5</div>
<div :class="['key', {active:active[6]}]" @touchstart="typing('6')">6</div>
<div :class="['key', {active:active[7]}]" @touchstart="typing('7')">7</div>
<div :class="['key', {active:active[8]}]" @touchstart="typing('8')">8</div>
<div :class="['key', {active:active[9]}]" @touchstart="typing('9')">9</div>
<div :class="['key' ,'dot',{active:active[12]}]" @touchstart="typing('.','12')">·</div>
<div :class="['key', {active:active[0]}]" @touchstart="typing('0')">0</div>
<div :class="['key', {active:active[10]}]" @touchstart="typing('00','10')">00</div>
</div>
<div class="tool">
<div :class="['key', 'del', 'iconfont', 'icon-jianpanshanchu',{active:active[11]}]" @touchstart="typing('del',11)"></div>
<div class="key confirm" @touchstart="complete">确定</div>
</div>
</div>
</div>
</transition>
</template>
<script>
export default {
props: {
show: {
type: Boolean,
default: true,
},
},
data(){
return{
active:[0,0,0,0,0,0,0,0,0,0,0,0,0],
}
},
methods: {
/*防止点击完成按钮左边的空白区域收起键盘*/
fn() { },
/*输入*/
typing(val,site) {
var site=site&&site!=='del'&&site!=="."?site:val;
this.active[site]=1
this.$set(this.active,site,1)
setTimeout(()=>{
this.$set(this.active,site,0)
},60)
this.$emit('typing', val);
},
/*点击完成*/
complete() {
this.$emit('complete');
}
}
}
</script>
移动端自定义键盘的vue组件 ----keyboard的更多相关文章
- 移动端自定义输入框的vue组件 ----input
<style scoped lang="less"> .keyboard { font-family: -apple-system, BlinkMacSystemFon ...
- 移动端无限滚动 TScroll.vue组件
// 先看使用TScroll.vue的几个demo 1.https://sorrowx.github.io/TScroll/#/ 2. https://sorrowx.github.io/TScrol ...
- vue.js之过滤器,自定义指令,自定义键盘信息以及监听数据变化
一.监听数据变化 1.监听数据变化有两种,深度和浅度,形式如下: vm.$watch(name,fnCb); //浅度 vm.$watch(name,fnCb,{deep:true}); //深度监视 ...
- vue教程2-08 自定义键盘信息、监听数据变化vm.$watch
vue教程2-08 自定义键盘信息 @keydown.up @keydown.enter @keydown.a/b/c.... 自定义键盘信息: Vue.directive('on').keyCode ...
- vue视频: 自定义指令 && 拖拽 && 自定义键盘信息
v-textv-forv-html 指令: 扩展html语法 自定义指令:1. 自定义属性指令: Vue.directive(指令名称,function(参数){ this.el -> 原生DO ...
- Vue.js 桌面端自定义滚动条组件|vue美化滚动条VScroll
基于vue.js开发的小巧PC端自定义滚动条组件VScroll. 前段时间有给大家分享一个vue桌面端弹框组件,今天再分享最近开发的一个vue pc端自定义滚动条组件. vscroll 一款基于vue ...
- Vue2.0的变化 ,组件模板,生命周期,循环,自定义键盘指令,过滤器
组件模板: 之前: <template> <h3>我是组件</h3><strong>我是加粗标签</strong> </templat ...
- 前端angularJS利用directive实现移动端自定义软键盘的方法
最近公司项目的需求上要求我们iPad项目上一些需要输入数字的地方用我们自定义的软键盘而不是移动端设备自带的键盘,刚接到需求有点懵,因为之前没有做过,后来理了一下思路发现这东西也就那样.先看一下实现之后 ...
- 基于React.js网页版弹窗|react pc端自定义对话框组件RLayer
基于React.js实现PC桌面端自定义弹窗组件RLayer. 前几天有分享一个Vue网页版弹框组件,今天分享一个最新开发的React PC桌面端自定义对话框组件. RLayer 一款基于react. ...
随机推荐
- USACO2006 Backward Digit Sums /// 全排列 oj24212
题目大意: 给出杨辉三角的顶点值M和底边数的个数 N (1 ≤ N ≤ 10) ,求出底边各个数的值,其中各个数范围都为1 ~ N 当N=4,M=16时可能是这样的 3 1 2 4 ...
- 【23. 合并K个排序链表】【困难】【优先队列/堆排序】
合并 k 个排序链表,返回合并后的排序链表.请分析和描述算法的复杂度. 示例: 输入: [ 1->4->5, 1->3->4, 2->6] 输出: 1->1-> ...
- 使用CSS3开启GPU硬件加速提升网站动画渲染性能
遇到的问题: 网站本身设计初衷就没有打算支持IE8及以下版本浏览器,并不是因为代码兼容性问题,而是真的不想迁就那些懒得更新自己操作系统和浏览器的用户,毕竟是我自己的网站,所以我说了算!哈哈~ 没有了低 ...
- 21-5-split
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- LINUX centos 7.2/7.3 搭建LAMP环境
首先我们先查看下centos的版本信息 #适用于所有的linux lsb_release -a #或者 cat /etc/redhat-release #又或者 rpm -q centos-relea ...
- Windows Server 2003服务器清理C盘空间的资料多个解决方法
一.关闭IIS HTTPRERR日志功能 默认情况下,2003服务器会把所有IIS访问错误的记录写入 C:WINDOWSsystem32LogFilesHTTPERR 下的 log 文件中,如果访问量 ...
- CodeForces - 803F
http://codeforces.com/problemset/problem/803/F #include <iostream> #include <cstdio> #in ...
- 廖雪峰Java16函数式编程-2Stream-4map
1. map()简介 Stream.map()是一个Stream的转换方法,把一个stream转换为另一个Stream,这2个Stream是按照映射函数一一对应的. 所谓map操作,就是把一种操作运算 ...
- CSS——before和after伪元素
之所以被称为伪元素,是因为他们不是真正的页面元素,html没有对应的元素,但是其所有用法和表现行为与真正的页面元素一样,可以对其使用诸如页面元素一样的css样式,表面上看上去貌似是页面的某些元素来展现 ...
- python相关软件安装流程图解——MySQL 8.0.13安装教程(windows 64位)——MYSQL依赖的软件——MYSQL必须的系统DLL插件——MYSQL真正的安装
https://www.mysql.com/https://www.mysql.com/downloads/https://dev.mysql.com/downloads/windows/https: ...