uniapp textarea中@input事件 回车
时间: 2023-10-09 16:16:33 浏览: 337
在uni-app中,textarea元素的@input事件不支持回车键。在手机端,没有键盘事件,所以不支持按键修饰符。如果你想实现在textarea中按下回车键触发事件的功能,可以使用@confirm事件。通过定义一个confirm-type属性为"search"的input元素,并在@confirm事件中执行你想要的操作,即可实现该功能。具体代码如下:
```html
<textarea v-model="content" confirm-type="search" @confirm="doSomething"></textarea>
```
其中,v-model指令用于双向绑定textarea的内容,confirm-type属性设置为"search",@confirm事件绑定一个方法doSomething,当用户在textarea中按下回车键时,会触发该方法。你可以在doSomething方法中编写你需要执行的代码。这样就能够在textarea中实现按下回车键触发事件的功能了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [uniapp 中input 判断输入enter (@keyup.13失效)](https://blog.csdn.net/qq_41767945/article/details/119676040)[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^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [uni-app单页开发@input 与@confirm 使用 仿淘宝搜索功能](https://blog.csdn.net/weixin_45923100/article/details/106797057)[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^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [UNI-APP_uni-app input监听回车键](https://blog.csdn.net/weixin_44599931/article/details/111026382)[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^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文