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 ...
随机推荐
- php 启动服务器监听
使用命令 php -S 域名:端口号 -t 项目路径 截图如下: 原本是通过localhost访问的 现在可以通过 127.0.0.1:8880 访问 此时命令行终端显示如下:
- I - Cows
来源 poj 3348 Your friend to the south is interested in building fences and turning plowshares into sw ...
- DOM内容操作
<table border="2"> <thead id="1" class="c1 c2"> <tr> ...
- 3D Slicer 4.7.0 VS 2010 Compile 编译
花了将近一周的时间的,终于在VS2010成功的编译了最新版的3D Slicer 4.7.0,感觉快要崩溃了.Slicer用了20多个外部的库,全都要一起编译,完整编译一次起码要七八个小时,光VS的Ou ...
- Docker 修改国内镜像地址
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://86d2a50b.m.daocloud.io 该脚本可以 ...
- 关于device tree中的interrupts选项
http://blog.csdn.net/jiang__jiang/article/details/52064715 随着Linux的发展,dts技术是大势所趋.里面的interrupts = < ...
- day7 七、字符编码,字符字节与文件操作
一.字符编码 1.定义:人类能识别的是字符等高级标识符,电脑只能识别0,1组成的标识符,要完成人与机器之间的信息交流,一定需要一个媒介,进行两种标识符的转化(两种标识符的对应关系) 对应关系形成的结构 ...
- p740+5802+外置磁带机连线
扩展柜型号5802 主柜型号p740 下图是连接线说明 需要连12X 和 SPCN 单个磁带机SAS线两根连接单个PCI否则,磁带无法提供多个分区使用 通过HMC或者查看资源情况 HMC配置Lpar分 ...
- 2018ACM-ICPC南京区域赛---AJGIDKM
含[最小球覆盖][最大流isap]模板. 题面pdf https://codeforc.es/gym/101981/attachments/download/7891/20182019-acmicpc ...
- SQL Server 2012 安装过程详解(包含每一步设置的含义)
转http://www.cnblogs.com/EastLiRoar/p/4051969.html 一.启动安装程序,点击“安装”选项卡,选择“全新SQL Server独立安装或向现有安装添加功能”. ...