vue project scan code gun collection

It will scan code gun sweep data into the input box to get the focus, and trigger input box enter Enter event

1. automatically get focus

 <el-input v-model="barCode" v-focus size="small"  @keyup.enter.native="payCode" ></el-input>

// 使用directives注册v-focus全局指令
  directives: {
    focus: {
      inserted: function(el) {
        el.querySelector("input").focus();
      }
    }
  },

2. Enter event monitor

payCode(){

  // here operation after scan code

}

 

Guess you like

Origin www.cnblogs.com/samsara-yx/p/11540394.html