1 Star 0 Fork 50

zd86 / avue-doc

forked from smallwei / avue-doc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
keyboard.md 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
smallwei 提交于 2020-05-30 20:51 . init docs
<script> export default { data() { return { // keys: [ // ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], // ['a', 'b', 'c', 'd', 'Shift', '清空'] // ], text: '', ele: 'text' } }, mounted() { this.$refs.text.focus(); // 自定义按键绑定click this.$refs.kb.bindClick("清空", () => { this[this.ele] = '' }) // 模拟更换输入框 setTimeout(() => { this.ele = "text2" }, 5000); }, methods: { // 键盘点击 handleKeyboardClick(key, val) { this[this.ele] = val } } } </script>

Keyboard 键盘组件

:::tip 2.2.0+ ::::

:::demo

<el-form :inline="true">
  <el-form-item label="输入框1">
    <el-input  ref="text" id="text" v-model="text" placeholder="点击我,完后用虚拟键盘输入"></el-input>
  </el-form-item>
</el-form>
<avue-keyboard ref="kb" :ele="ele" :keys="keys" @click="handleKeyboardClick" style="width: 800px; height: 300px">
</avue-keyboard>
<script>
export default {
  data() {
      return {
        // keys: [
        //   ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
        //   ['a', 'b', 'c', 'd', 'Shift', '清空']
        // ],
        text: '',
        ele: 'text'
      }
    },
    mounted() {
      this.$refs.text.focus();
      // 自定义按键绑定click
      this.$refs.kb.bindClick("清空", () => {
        this[this.ele] = ''
      })

      // 模拟更换输入框
      setTimeout(() => {
        this.ele = "text2"
      }, 5000);
    },
    methods: {
      // 键盘点击
      handleKeyboardClick(key, val) {
        this[this.ele] = val
      }
    }
}
</script>

:::

Variables

参数 说明 类型 可选值 默认值
type 键盘类型 String default/number default
theme 主题 String default/green/dark/classic default








马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/86zhangdong/avue-doc.git
git@gitee.com:86zhangdong/avue-doc.git
86zhangdong
avue-doc
avue-doc
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891