vue项目中如何利用v-on:blur
监听失焦事件,下面web建站小编给大家简单介绍一下!
具体语法如下:
<template> <div> <label for="username">用户名:</label> <input type="text" id="username" v-model="username" @blur="checkUsername"> <div v-show="showErrorMsg">{{errorMsg}}</div> </div> </template> <script> export default { data() { return { username: '', showErrorMsg: false, errorMsg: '' } }, methods: { checkUsername() { // 这里我们简单判断用户名是否为空 if (this.username === '') { this.showErrorMsg = true this.errorMsg = '用户名不能为空' } else { this.showErrorMsg = false } } } } </script>
标签: v-on:blur, vue失焦事件, vue监听事件
上面是“vue中如何利用v-on:blur监听失焦事件”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4879.html
workflows工作流
一轮月亮悬挂在树上的天空中ComfyUI工作流
哈利波特魔法ComfyUI工作流
池塘边的大熊猫ComfyUI工作流
一个可爱的口袋妖怪ComfyUI工作流
1个很漂亮的单身小女孩ComfyUI工作流
乒乓卡通3d人物
一只张大嘴巴露出锋利的牙齿正在咆哮的雪豹
一杯咖啡蒸汽形成云ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!