移动端自定义键盘的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. ...
随机推荐
- python学习3—数据类型之整型、字符串和布尔值
python学习3-数据类型之整型.字符串和布尔值 数据类型 python3支持的数据类型共有6种: 1 Number 2 String 3 List 4 Tuple 5 Set 6 Dictiona ...
- Android笔记之从图库选择图片
Demo链接:https://pan.baidu.com/s/1T4T2pTEswmbcYYfpN3OwDw,提取码:pzqy 参考链接:[Android Example] Pick Image fr ...
- PyQt5 安装及简单实例 -- 标签设置
- 1 - PyQt5安装,鉴于pip工具,安装其实很简单, 如下:(最好将pip索引配置成国内镜像,速度比默认的快得多) pip3 isntall PyQt5 - 2 - 利用Pycha ...
- 关于UIPageViewController去除边缘点击手势
如果page上方还有一层UI控件的话,不去除边缘点击手势会造成手势的冲突干扰. 首先我做的处理是设置pageView的手势代理 for (UIGestureRecognizer *gr in _pag ...
- php curl的正确使用方法
在做一个读取远程抓取数据并显示的demo的时候,遇到了以下几个问题: 1.用的curl变量进行了多定义 2.抓取远程数据时没有返回正确的json数据 没有返回正确的json数据不是因为网站提供的接口问 ...
- 正则表达式r和re
# coding:utf-8 import re print 'a\ws' print r'a\nb' # r'': 一般用在正则表达式中,称为原始字符串,作用是将Python语法中的反斜杠转义给 取 ...
- UVA 511 Do You Know the Way to San Jose?
题目链接:https://vjudge.net/problem/UVA-511 题目翻译摘自<算法禁赛入门经典> 题目大意 有 n 张地图(已知名称和某两个对角线端点的坐标)和 m 个地名 ...
- python 安装bs4
1, 下载地址https://www.crummy.com/software/BeautifulSoup/#Download ------------------------------------- ...
- this关键字、static关键字、block块、封装类以及继承、import、修饰符的初步了解
this关键字 定义 在类的方法定义中使用this关键字代表使用该方法的引用. this即"自己",代表对象本身,谁调用代表谁.在成员方法中或构造器中隐式的传递. this的两种用 ...
- Python flask 构建微电影视频网站✍✍✍
Python flask 构建微电影视频网站 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大 ...