// html
<input
type="text"
ref="search"
placeholder="请输入..."
size="mini"
@keyup.native="toComplete"
>
// data数据
data() {
return {
pingProcess: 0,
}
}
// 方法
methods: {
toComplete(e) {
if (e.keyCode == 229 && e.key == "Process") {
console.log("*** 输入法切换")
this.pingProcess = true; // 拼音输入法
}
// && isNaN(parseInt(e.key)) 输入的非数字
// e.keyCode !== 8 --- 删除
// e.keyCode !== 229 输入法会一次出发两次 先触发229 后触发输入的键位 比如a -- 65
// this.pingProcess 前面先监听了输入法后面再次判断这个值表示正在输入
// isNaN(parseInt(e.key)) 这个是键位判断 是选择的数子键位 e.keyCode !== 32 空格
if (e.keyCode !== 8 && e.keyCode !== 229 && e.keyCode !== 32 && this.pingProcess && isNaN(parseInt(e.key))){
console.log("正在输入")
this.search_show = '';
this.pingProcess = false;
console.log("********")
}else{
if (e.keyCode !== 229){
this.pingProcess = false;
console.log("确认输入:")
}
}
}
}版权声明:本文为Edwin_jade原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。