vue-自定义pc端软键盘
<template>
<div>
<el-input v-model="money" type="textarea" placeholder="请输入内容"></el-input>
<div class="keyboard">
<div class="keyboard_key">
<div class="keyboard_character" @click="_chraClick">
<button type="button" class="pad-num1 specialkey" data-num='!'>!</button>
<button type="button" class="pad-num1 specialkey" data-num='@'>@</button>
<button type="button" class="pad-num1 specialkey" data-num='#'>#</button>
<button type="button" class="pad-num1 specialkey" data-num='$'>$</button>
<button type="button" class="pad-num1 specialkey" data-num='%'>%</button>
<button type="button" class="pad-num1 specialkey" data-num='^'>^</button>
<button type="button" class="pad-num1 specialkey" data-num='&'>&</button>
<button type="button" class="pad-num1 specialkey" data-num='*'>*</button>
<button type="button" class="pad-num1 specialkey" data-num='('>(</button>
<button type="button" class="pad-num1 specialkey" data-num=')'>)</button>
<button type="button" class="pad-num1 specialkey" data-num='{'>{</button>
<button type="button" class="pad-num1 specialkey" data-num='}'>}</button>
<button type="button" class="pad-num1 specialkey" data-num=':'>:</button>
<button type="button" class="pad-num1 specialkey" data-num='"'>"</button>
<button type="button" class="pad-num1 specialkey" data-num=','>,</button>
<button type="button" class="pad-num1 specialkey" data-num='/'>/</button>
</div> <div class="centerdiv"></div> <div class="keyboard_Letter">
<div class="group1">
<button v-for="(item,index) in keylist" :key="index" type="button" class="pad-num1" @click="upClick1(item)">{{item}}</button>
</div> <div class="group2">
<button v-for="(item,index) in keylist2" :key="index" type="button" class="pad-num1" @click="upClick2(item)">{{item}}</button>
</div> <div class="group3">
<button v-for="(item,index) in keylist3" :key="index" type="button" class="pad-num1" @click="upClick3(item)" >{{item}}</button>
</div>
<div class="group4" @click="_letterClick">
<button type="button" class="pad-num1 specialkey" data-num='delete'>delete</button>
<button type="button" class="pad-num2 specialkey" data-num='space'>space</button>
<button type="button" class="pad-num1 specialkey" data-num='enter'>
<i class="fa fa-mail-reply" data-num='enter'></i>
</button>
</div> </div> <div class="centerdiv"></div> <div class="keyboard_number" @click="_handleKeyPress">
<div class="pos-right-pad-num">
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num=''></button>
<button type="button" class="pad-num specialkey" data-num='.'>.</button>
<button type="button" class="pad-num specialkey" data-num='D'>X</button>
</div>
<div class="pos-right-pad-act">
<button type="button" class="pad-num specialkey border-right" style="width:100%" data-num='+'>+</button>
<button type="button" class="pad-num specialkey border-right" style="width:100%" data-num='-'>-<br></button>
<button type="button" class="pad-num2 specialkey border-right" data-num='enter'><i class="fa fa-mail-reply" aria-hidden="true"></i></button>
</div>
</div>
</div>
</div>
</div>
</template> <script>
export default {
data() {
return {
money: "",
keylist: [],
keylist2: [],
keylist3: [],
bigkeys1:[],
bigkeys2:[],
bigkeys3:[],
smallkeys1:[],
smallkeys2:[],
smallkeys3:[],
selected:false
};
},
created() {
this.readle();
},
methods: {
readle() {
let smallkey1 = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"];
let bigkey1 = ["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"];
let smallkey2 = ["a", "s", "d", "f", "g", "h", "j", "k", "l"];
let bigkey2 = ["A", "S", "D", "F", "G", "H", "J", "K", "L"];
let smallkey3 = ["shift", "z", "x", "c", "v", "b", "n", "m", "<", ">"];
let bigkey3 = ["SHIFT","Z", "X", "C", "V", "B", "N", "M", "<", ">"];
this.keylist = smallkey1;
this.keylist2 = smallkey2;
this.keylist3 = smallkey3;
this.bigkeys1=bigkey1;
this.bigkeys2=bigkey2;
this.bigkeys3=bigkey3;
this.smallkeys1=smallkey1;
this.smallkeys2=smallkey2;
this.smallkeys3=smallkey3;
},
_chraClick(e) {
let num = e.target.dataset.num;
this.money += num;
this.$emit("updatekey",this.money);
},
_handleKeyPress(e) {
let num = e.target.dataset.num;
switch (String(num)) {
case "D":
this.deletekey();
break;
case "enter":
this.money+="\n";
break;
default:
this.Addnum(num);
break;
}
this.$emit("updatekey",this.money)
},
deletekey() {
let values = this.money;
if (!values.length) {
return false;
} else {
this.money = values.substring(, values.length - );
this.$emit("updatekey",this.money)
}
},
Addnum(num) {
let value = this.money;
this.money = value + num;
},
upClick1(key){
this.money+=key;
this.$emit("updatekey",this.money)
},
upClick2(key){
this.money+=key;
this.$emit("updatekey",this.money)
},
upClick3(key){
switch(String(key))
{
case "shift":
this.keylist=this.bigkeys1;
this.keylist2=this.bigkeys2;
this.keylist3=this.bigkeys3;
break;
case "SHIFT":
this.keylist = this.smallkeys1;
this.keylist2 = this.smallkeys2;
this.keylist3 = this.smallkeys3;
break;
default:
this.money+=key;
break;
}
this.$emit("updatekey",this.money)
},
_letterClick(e){
let num = e.target.dataset.num;
switch(String(num))
{
case "delete":
this.deletekey();
break;
case "space":
this.money +=" ";
break;
case "enter":
this.money +="\n";
break;
}
},
}
};
</script>
<style lang="scss" scoped>
.keyboard {
width: %;
height: 215px;
background: #;
opacity: 0.7;
overflow: hidden;
}
.keyboard_key {
padding-top: 10px;
width: %;
display: flex;
flex-direction: row;
justify-content: space-between;
}
button {
background-color: aliceblue;
}
// ----数字键盘-----
.keyboard_number {
display: flex;
width: %;
margin: ;
padding: ;
vertical-align: bottom;
flex-direction: row;
justify-content: space-between;
flex-wrap: wrap;
align-items: center;
}
.pos-right-pad-num {
display: flex;
width: %;
flex-direction: row;
justify-content: space-between;
flex-wrap: wrap;
align-items: center;
}
.pos-right-pad-act {
width: %;
}
.pad-num {
margin: !important;
width: 33.3333333%;
height: 48px;
border: ;
border: 1px solid #;
font-size: 15px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
.pad-num2 {
margin: !important;
width: %;
height: 96px;
border: ;
border: 1px solid #;
font-size: 15px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
} // 字符键盘
.keyboard_character {
width: %;
margin: ;
padding: ;
display: flex;
flex-direction: row;
justify-content: space-between;
flex-wrap: wrap;
align-items: center;
margin-left: %;
.pad-num1 {
width: %;
height: 48px;
border: 1px solid #;
font-size: 15px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
} //字母键盘
.keyboard_Letter {
width: %;
margin: ;
padding: ;
.group1 {
display: flex;
flex-direction: row;
.pad-num1 {
width: %;
height: 48px;
border: 1px solid #;
font-size: 15px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
}
.group2 {
display: flex;
flex-direction: row;
width: %;
margin-left: 26px;
.pad-num1 {
width: %;
height: 48px;
border: 1px solid #;
font-size: 15px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
} .group3 {
display: flex;
flex-direction: row;
.pad-num1 {
width: %;
height: 48px;
border: 1px solid #;
font-size: 16px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
}
.group4 {
display: flex;
flex-direction: row;
.pad-num1 {
width: %;
height: 48px;
font-size: 16px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
.pad-num2 {
width: %;
height: 48px;
border: 1px solid #;
font-size: 16px;
cursor: pointer;
&:hover {
position: relative;
cursor: pointer;
}
&:active {
top: 1px;
left: 1px;
background-color: #201a1a;
}
}
}
}
.centerdiv {
border-right: 2px solid rgb(, , );
padding-bottom: 1800px; /*关键*/
margin-bottom: -1800px; /*关键*/
padding-top: 1800px; /*关键*/
margin-top: -1800px; /*关键*/
}
.input-box {
font-size: 35px;
font-weight: bold;
height: 40px;
border-bottom: 1px solid #aaa;
padding: 10px 15px;
text-align: right;
width: %;
}
</style>
<template>
<div>
<h1>父组件</h1>
<textarea type="text" v-model="keyboards"></textarea>
<keyboard v-on:updatekey="GetKeyVal"></keyboard>
</div>
</template> <script>
import Keyboard from './Keyboard' export default {
data() {
return {
keyboards:""
}
},
components: {
Keyboard
},
methods:{
GetKeyVal(val){
this.keyboards=val;
}
},
}
</script> <style lang="scss" scoped>
#app {
width: 680px;
margin: 20px auto;
font-family: Verdana, Sans-Serif; h1 {
color: #42b983;
font-weight: bold; } textarea {
display: block;
width: %;
min-height: 100px;
padding: ;
margin: 20px ;
font-size: 16px;
}
}
</style>
vue-自定义pc端软键盘的更多相关文章
- 自定义View 实现软键盘实现搜索
1. xml文件中加入自定义 搜索view <com.etoury.etoury.ui.view.IconCenterEditText android:id="@+id/search_ ...
- Ionic3学习笔记(九)关于 Android 端软键盘弹出后界面被压缩的问题
本文为原创文章,转载请标明出处 今天做了一个如下图所示的页面. iOS 端毫无 bug,Android 端却出现了问题.当软键盘弹出后,Android 端的 tabs 移到了软键盘的上面,再仔细一看, ...
- vue实现PC端分辨率适配
lib-flexible + px2rem Loader lib-flexible 阿里伸缩布局方案 px2rem-loader:px转rem: 依赖 首先需要安装 vue-cli 脚手架,这里我安装 ...
- web中ios移动端软键盘收起后,页面内容留白不下滑
微信里面打开web页面,在ios软键盘收起时,页面键盘位置的内容留白,如下图 这个问题纠结了很久,然后请教了老大(威哥),看到页面老大给出的方案就是代码改变滚动条的位置. 这里就监听键盘收起的事件,来 ...
- 可编辑DIV与移动端软键盘兼容性问题汇总
此文复现的所有兼容性问题均为以下情况: 1. 腾讯X5内核 2. 全屏webview 问题如下: 1. IOS12 中软键盘弹出导致页面顶部截断,并且无法恢复. 解决方法:添加交互事件,调用本地方法, ...
- vue实现PC端调用摄像头拍照人脸录入、移动端调用手机前置摄像头人脸录入、及图片旋转矫正、压缩上传base64格式/文件格式
进入正题 1. PC端调用摄像头拍照上传base64格式到后台,这个没什么花里胡哨的骚操作,直接看代码 (canvas + video) <template> <div> &l ...
- vue实现pc端无限加载功能
主要思路通过自定义指令,在视图初始化完成后,绑定scroll事件.当scrollTop + clientHeight >= scrollHeight时(此时滚定条到了底部)触发loadMore事 ...
- IOS微信端软键盘收起后界面按钮失效问题
问题描述: 1.在vue里封装了一个confirm的弹窗(即如下一个弹窗) 2.发现在IOS微信客户端中打开后,当需要在表单中输入内容的时候,很自然的点击了键盘右上角的[完成]按钮 3.啊~~~,惊人 ...
- vue 自定义 移动端筛选条件
1.创建组件 components/FilterBar/FilterBar.vue <template> <div class="filterbar" :styl ...
随机推荐
- IOError: cannot open resource
在运行PIL_test.py文件的时候报错: File "PIL_test.py", line 40, in <module> font = ImageFont.tru ...
- PHP开启伪静态(AppServ服务器)
mod_rewrite是Apache的一个非常强大的功能,它可以实现伪静态页面.下面我详细说说它的使用方法 1.检测Apache是否支持mod_rewrite 通过php提供的phpinfo()函数查 ...
- C#枚举类型和int类型相互转换
C#枚举类型和int类型相互转换 C# 枚举(Enum) 枚举是一组命名整型常量.枚举类型是使用 enum 关键字声明的. C# 枚举是值数据类型.换句话说,枚举包含自己的值,且不能继承或传递继承. ...
- [原]openstack-kilo--issue(十六) instance can't get ip 虚拟机不能得到ip(1)
=====问题点:vm instance不能正常获取ip地址(此时用户是:admin) =======不一样的点:如果使用用户demo用户,启动一个vm,同样的image这个时候就能正确获取ip == ...
- 正则表达式中,[\s\S]* 什么意思
https://blog.csdn.net/haoyuedangkong_fei/article/details/53781936 例如:[a-z]表示从a到z之间的任意一个. 不是这样的吗?谁能给我 ...
- jquery-1.11.2.min.js
/*! jQuery v1.11.2 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ !function(a,b){& ...
- 洛谷P1908 逆序对【递归】
题目:https://www.luogu.org/problemnew/show/P1908 题意:给定一个数组,求逆序对个数. 思路: 是一个很经典的题目了.通过归并排序可以求逆序对个数. 现在有一 ...
- Echarts 的Formatter的回调函数
option = { tooltip: { trigger: 'axis', formatter: function (params,ticket,callback) { let res = para ...
- 阿里云VPC服务器通过ClassicLink访问经典网络服务器
VPC中的服务器名称是 vpc-ecs1 , 经典网络中的服务器名称是 classic-ecs2 ,要实现 vpc-ecs1 通过内网访问 classic-ecs2 . VPC 网段是 10.0.0. ...
- 泡泡一分钟:Motion Planning for a Small Aerobatic Fixed-Wing Unmanned Aerial Vehicle
Motion Planning for a Small Aerobatic Fixed-Wing Unmanned Aerial Vehicle Joshua Levin, Aditya Paranj ...