vue输入框回车搜索
时间: 2023-09-10 10:14:05 浏览: 387
在Vue中,想要实现输入框回车搜索的功能,可以通过在`<input>`标签内部添加`@keyup.enter`事件来实现。具体代码如下所示:
```
<div class="center">
<input placeholder="输入名称" v-model="keyword" @keyup.enter="getsearchdata">
</div>
<div class="seal" @click="getsearchdata">搜索</div>
```
其中,`@keyup.enter`事件会在用户按下回车键时触发相应的搜索方法`getsearchdata`。这样,在输入框内输入内容后直接按回车键就可以进行搜索操作了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Vue按回车键进行搜索](https://blog.csdn.net/m0_58565372/article/details/128188212)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [【解决】vue使用input输入框绑定回车事件,触发就会刷新页面](https://blog.csdn.net/ddd295569371/article/details/130243013)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文