Android 扫码枪 文本框输入框,获取焦点,禁止弹出键盘 插件
使用的是 nvue 页面引用
复制代码<scan-edit ref="scan" textSize="16" @afterTextChanged="afterTextChanged" ></scan-edit>
在 nvue 页面中,插入 scan-edit 标签,它是一个输入框,普通的输入框获取焦点会弹出键盘,而它不会弹出盘键,方便扫码枪工作。
属性
属性 | 说明 | 类型 |
---|
textSize | 字体大小 | int |
textColor | 字体颜色 | string 例如:#999 |
hint | 提示语 | string |
hintTextColor | 字体颜色 | string 例如:#999 |
方法
方法 | 说明 |
---|
afterTextChanged | 监听文本内容变化 |
focus | 获得焦点 |
blur | 失去焦点 |
setText | 设置文本框内容 |
showKeyboard | 显示键盘 |
hideKeyboard | 显示键盘 |
示例
复制代码<template>
<div>
<scan-edit ref="scan"
textSize="16"
@afterTextChanged="afterTextChanged"
textColor="#999999"
class="input"
></scan-edit>
<button @click="focus">获得焦点</button>
<button @click="blur">失去焦点</button>
<button @click="showKeyboard">显示键盘</button>
<button @click="hideKeyboard">隐藏键盘</button>
<button @click="empty">清空内空</button>
<text>{{tip}}</text>
</div>
</template>
<script>
export default {
data() {
return {
tip:""
}
},
onReady() {
this.$refs.scan.focus();
},
methods: {
focus()
{
this.$refs.scan.focus();
},
blur()
{
this.$refs.scan.blur();
},
afterTextChanged(e)
{
let text=e.detail.text;
this.tip=text;
},
showKeyboard()
{
this.$refs.scan.showKeyboard();
},
hideKeyboard()
{
this.$refs.scan.hideKeyboard();
},
empty()
{
this.$refs.scan.setText("");
}
}
}
</script>
<style>
.input{ margin: 10px; height:150px; width:300px; padding-left: 10px;
border-style: solid;
border-left-color:#999;
border-left-width: 1px;
border-top-color:#999;
border-top-width: 1px;
border-right-color:#999;
border-right-width: 1px;
border-bottom-color:#999;
border-bottom-width: 1px;
border-radius:5px; }
</style>
加载更多