该文章或问题已被删除

Android 扫码枪 文本框输入框,获取焦点,禁止弹出键盘

价 格: ¥19.90

简 介: 扫码枪 文本框输入框,获取焦点,禁止弹出键盘

跳转到 uniapp 插件市场

详细内容

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>

0 个回答

正在加载...

这里空空如也,快来补一刀!

加载更多

回答问题或评论文章请先 或者 注册