移动端自定义键盘的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. ...
随机推荐
- elasticsearch的基本用法(转载)
本文出自:http://blog.csdn.net/feelig/article/details/8499614 最大的特点: 1. 数据库的 database, 就是 index 2. 数据库 ...
- 解决WIN8输入法的问题,Ctrl+空格,Ctrl+Shift,切换问题
在WIN8中,我们曾经熟悉的的Ctrl+空格和Ctrl+Shift消失了,取而导致的是WIN+空格. 在这里先简单解释一下WIN8的输入法结构: 在WIN7以前的输入法中,输入法采用了平行目录的结构, ...
- java面试官如何面试别人
java面试官如何面试别人(一) j ...
- Linux 实用指令(9)--进程管理
目录 进程管理 1 进程的基本介绍 2 显示系统执行的进程 2.1 说明: 2.2 ps指令详解 2.3 应用实例 3 终止进程kill和killall 3.1 介绍 3.2 基本语法 3.3 常用选 ...
- layer.confirm等事件X关闭与取消监听
关于layer.confirm的所有操作 layer.confirm('content',{ btn:['确定','取消'], cancel:function(index, layero){ cons ...
- leetcode-8-字符串转换整数(atoi)
题目描述: 方法一:正则 class Solution: def myAtoi(self, str: str) -> int: return max(min(int(*re.findall('^ ...
- 校园商铺-4店铺注册功能模块-5店铺注册之Service层的实现
1. 创建接口 ShopService.java package com.csj2018.o2o.service; import java.io.File; import com.csj2018.o2 ...
- R语言 循环
R语言循环 可能有一种情况,当你需要执行一段代码几次. 通常,顺序执行语句. 首先执行函数中的第一个语句,然后执行第二个语句,依此类推. 编程语言提供允许更复杂的执行路径的各种控制结构. 循环语句允许 ...
- Acess link
- typedef void (*funcptr)(void) typedef void (*PFV)(); typedef int32_t (*PFI)();
看到以下代码,不明白查了一下: /** Pointer to Function returning Void (any number of parameters) */ typedef void (* ...