由於部分場景需要屏蔽掉文本框輸入法
如讀卡器,若卡號為abcefg32,則讀卡器輸出為:ABC得分過(不同輸入結果不同),如圖:
當輸入中文abcdefg時:

當繼續輸入3時:

當繼續輸入最后數字2時:

對於IE,火狐瀏覽器,設置ime-mode: disabled即可解決(屏蔽輸入法)
<input type="text" style="ime-mode: disabled;">
根據讀卡器(以我接觸過的舉例)通過刷卡,在光標位於可輸入文本的地方進行刷卡,則讀出內容寫入光標位置。
如此可通過獲取focus和change事件,配合password(不可切換輸入法)來變相實現“屏蔽輸入法”。
ICPswChange(value){
//取值處理
//業務處理
//將value賦值給只讀的input type="text"標簽
document.getElementById('icinput').value = value;
//將value賦值給隱藏的input type="password"
document.getElementById('icpsw').value = value;
// 避免重復刷卡、讀卡
document.getElementById("icpsw").blur();
//其他處理
}
ICInputFocus(){
//置空隱藏窗口值
document.getElementById('icpsw').value='';
document.getElementById('icinput').value = '';
//設置光標至password隱藏輸入窗口
document.getElementById("icpsw").focus();
}
<el-form-item label="IC門禁卡">
<el-input v-model="editDialog.form.icCardNo" id="icinput" auto-complete="off" class="handle-input-plus" readonly="readonly" v-on:focus="ICInputFocus"></el-input>
<el-input id="icpsw" type="password" style="border:0px;background:none;opacity:0.0" @change="ICPswChange"></el-input>
</el-form-item>