移动端自定义键盘

在这里插入图片描述
代码**:html**

<van-popup v-model="NumberShow" position="bottom">
  <div class="number_title flex alic justs">
    <img :src="images[1]" alt @click="NumberShow=false" class="img ml15" />
    <div class="center fz15">输入血糖</div>
    <img :src="images[0]" alt @click="confirmEvent(value)" class="img mr15" />
  </div>
  <div class="number_input flex alic justc bgf">
    <div v-if="!value" class="fz50 mr5 color1F">0.0</div>
    <div v-else class="fz50 mr5 color1F">{{value}}</div>
    <div class="fz12 mt20">mmol/L</div>
  </div>
  <div class="two_btn flex alic tc bgf fz30">
    <div class="w50 low" @click="confirmEvent('low')">low</div>
    <div class="w50 high" @click="confirmEvent('high')">high</div>
  </div>
  <div class="number_key flex alic wrap">
    <div
      class="item w33 tc fz30 fw9"
      v-for="item in arr"
      :key="item"
      @click="onInput(item)"
    >{{item}}</div>
    <div class="item w33 tc fz30 fw9" @click="onDelete">删除</div>
  </div>
</van-popup>

style
/* 键盘 */
.number_title {
height: 0.51rem;
line-height: 0.51rem;
text-align: center;
background: #f0f0f4;
}
.leftofright_icon {
height: 0.25rem;
width: 0.38rem;
}
.center {
flex: 1;
}
.number_input {
height: 1.5rem;
}

.two_btn {
height: 0.6rem;
border-top: 0.01rem dashed #999;
border-bottom: 0.01rem dashed #999;
line-height: 0.6rem;
background: #f0f0f4;
}
.w50 {
width: 50%;
}
.low {
color: #88d5ff;
border-right: 0.01rem dashed #999;
}
.high {
color: #e75900;
}
.number_key {
background: #f0f0f4;
}
.item {
/* width: calc(100% / 3); */
height: 0.6rem;
line-height: 0.6rem;
border-bottom: 0.01rem dashed #999;
border-right: 0.01rem dashed #999;
}
.item:nth-child(3),
.item:nth-child(6),
.item:nth-child(9),
.item:nth-child(12) {
border-right: none;
}
js
// 展示数字键盘
keyboard() {
this.value = “”;
this.NumberShow = true;
},
// 键盘事件
onInput(value) {
console.log(value);
if (this.value.length > 5) {
return;
}
this.value = this.value + value;
console.log(this.value);
},
//键盘删除功能
onDelete() {
this.value = this.value.slice(0, -1);
console.log(this.value);
},
confirmEvent(value) {
this.value = value;
this.form.bloodPressure = value;
console.log(this.value);
this.NumberShow = false;
// this.$emit(“confirm”, this.value);
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值