<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的更多相关文章

  1. 移动端自定义输入框的vue组件 ----input

    <style scoped lang="less"> .keyboard { font-family: -apple-system, BlinkMacSystemFon ...

  2. 移动端无限滚动 TScroll.vue组件

    // 先看使用TScroll.vue的几个demo 1.https://sorrowx.github.io/TScroll/#/ 2. https://sorrowx.github.io/TScrol ...

  3. vue.js之过滤器,自定义指令,自定义键盘信息以及监听数据变化

    一.监听数据变化 1.监听数据变化有两种,深度和浅度,形式如下: vm.$watch(name,fnCb); //浅度 vm.$watch(name,fnCb,{deep:true}); //深度监视 ...

  4. vue教程2-08 自定义键盘信息、监听数据变化vm.$watch

    vue教程2-08 自定义键盘信息 @keydown.up @keydown.enter @keydown.a/b/c.... 自定义键盘信息: Vue.directive('on').keyCode ...

  5. vue视频: 自定义指令 && 拖拽 && 自定义键盘信息

    v-textv-forv-html 指令: 扩展html语法 自定义指令:1. 自定义属性指令: Vue.directive(指令名称,function(参数){ this.el -> 原生DO ...

  6. Vue.js 桌面端自定义滚动条组件|vue美化滚动条VScroll

    基于vue.js开发的小巧PC端自定义滚动条组件VScroll. 前段时间有给大家分享一个vue桌面端弹框组件,今天再分享最近开发的一个vue pc端自定义滚动条组件. vscroll 一款基于vue ...

  7. Vue2.0的变化 ,组件模板,生命周期,循环,自定义键盘指令,过滤器

    组件模板: 之前: <template> <h3>我是组件</h3><strong>我是加粗标签</strong> </templat ...

  8. 前端angularJS利用directive实现移动端自定义软键盘的方法

    最近公司项目的需求上要求我们iPad项目上一些需要输入数字的地方用我们自定义的软键盘而不是移动端设备自带的键盘,刚接到需求有点懵,因为之前没有做过,后来理了一下思路发现这东西也就那样.先看一下实现之后 ...

  9. 基于React.js网页版弹窗|react pc端自定义对话框组件RLayer

    基于React.js实现PC桌面端自定义弹窗组件RLayer. 前几天有分享一个Vue网页版弹框组件,今天分享一个最新开发的React PC桌面端自定义对话框组件. RLayer 一款基于react. ...

随机推荐

  1. 生产环境Docker部署ELK跨区访问kafka不通问题的解决

    由于分布式系统的日志集中采集的需求非常强烈,我们组通过调研和实践搭建了一套基于Docker的日志收集系统Amethyst. 我们首先在测试环境搭建了一套基于Docker swarm集群的ELK分布式环 ...

  2. StringBuilder 和 StringBuffer类

    通常在涉及到StringBuilder和StringBuffer时中任何一个时,都应该想到另外一个并且在脑海中问自己是否用另外一个更加合适. 为什么这么说,请继续往下看,当然如果你已经对二者烂熟于胸自 ...

  3. js实现图片资源、blob、base64的各种场景转换

    文件转babase64 function getImgToBase64(url,callback){//将图片转换为Base64 var canvas = document.createElement ...

  4. 服务启动脚本start_boot.sh

    vim start_boot.sh #!/bin/bash usage(){ echo "$0 [start|stop|usage]" } status_springboot(){ ...

  5. Centos6 安装完之后,没有网络

    Virtualbox安装的centos 6.10的虚拟机,安装时,网络是NAT网络,安装完之后,将网络改为桥接网卡,启动虚拟机之后,使用 ifconfig 命令查看没有到eth0的信息,只有127.0 ...

  6. leetcode-5-最长回文子串*马拉车

    方法一:动态规划 O(n2) O(n2) class Solution: def longestPalindrome(self, s: str) -> str: size = len(s) if ...

  7. 暴力剪枝——cf1181C

    暴力求长度为len时,以i,j为左上角的旗子的数量 不剪枝的话复杂度是n*n*m*n,必定超时 两个可以剪枝的地方:如果格子[i,j]可以作为长度为len的旗子的左上角,那么其必定不可以作为长度> ...

  8. el-upload文件上传组件

    一.介绍 element-ui的组件之一,用来点击上传文件 官方是使用 before-upload 限制用户上传的图片格式和大小.但是某些浏览器不支持此方法,所以使用on-change来代替. 二.代 ...

  9. WinDBG常用断点命令

    WinDBG提供了多种设断点的命令: bp 命令是在某个地址 下断点, 可以 bp 0x7783FEB 也可以 bp MyApp!SomeFunction . 对于后者,WinDBG 会自动找到MyA ...

  10. Java-Maven-pom.xml-porject-parent:parent

    ylbtech-Java-Maven-pom.xml-porject-parent:parent 1.返回顶部 1.Inherit defaults from Spring Boot <!-- ...