<template>
<div>
<input type="text" placeholder="请输入搜索内容" v-model="currentLevel">
<img src="xx/search.png" @click="searchData()"
@keyup.enter="keyDown($event)" />
</div>
</template>
<script>
export default {
data() {
return {
currentLevel: ""
}
},
mounted() {
window.addEventListener("keydown", this.keyDown);
},
methods: {
keyDown(e) {
if (e.key == 'Enter') {
this.searchData();
e.preventDefault(); // 去掉默认的换行
}
},
searchData() {
}
},
beforeDestroy: function() {
window.addEventListener("keydown", this.keyDown);
}
}
</script>
vue表格搜索的时候回车按键
最新推荐文章于 2024-08-23 13:45:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)