uniapp——自定义input清除事件

摘要:
效果图如下:HTML:接受数字的人的姓名:˂textclass=“iconfonti

效果图如下:

uniapp——自定义input清除事件第1张

 HTML:

<view class="disF">
                        <view class="qhItem">
                            <view class="m-qhTit">取号人姓名:</view>
                            <view class="qhInput uni-input-wrapper">
                                <input type="text" placeholder="请填写取号人姓名" v-model="cusname" />
                                <text class="iconfont iconshanchu" v-if="cusname.length>0" @click="cusname=''"></text>
                            </view>
                        </view>
                        <view class="qhItem">
                            <view class="m-qhTit">手机号:</view>
                            <view class="qhInput uni-input-wrapper">
                                <input type="number" placeholder="请填写手机号" v-model="mobile" />
                                <text class="iconfont iconshanchu" v-if="mobile.length>0" @click="mobile=''"></text>
                            </view>
                        </view>
                        <view class="qhItem">
                            <view class="m-qhTit">排队号:</view>
                            <view class="qhInput uni-input-wrapper">
                                <input type="number" placeholder="请填写排队号" v-model="number" />
                                <text class="iconfont iconshanchu" v-if="number.length>0" @click="number=''"></text>
                            </view>
                        </view>
                    </view>

CSS:

.disF{
                    display: flex;
                     730px;
                    .qhItem{
                         33%;
                        .m-qhTit{
                            min- 85px;
                            height: 34px;
                            line-height: 34px;
                            font-size: 14px;
                            text-align: right;
                            margin-right: 6px;
                        }
                        .qhInput{
                            position: relative;
                            input{
                                 144px;
                                height: 34px;
                                line-height: 34px;
                                border: 1px solid #ccc;
                                padding: 0 8px;
                                font-size: 14px;
                                border-radius: 2px;
                            }
                            .iconshanchu{
                                font-size: 16px;
                                color: #ccc;
                                position: absolute;
                                top: 3px;
                                right: 15px;
                                cursor: pointer;
                            }
                        }
                    }
                }

js:

uniapp——自定义input清除事件第2张

 

归纳总结:

1.data中声明变量

2.input绑定变量

3.清除按钮:判断变量的长度,如果大于0点击click事件清空值

免责声明:文章转载自《uniapp——自定义input清除事件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇OpenWrt上搭建纯L2TP服务器[ZT]ssh登录时在参数中加入密码的解决方案下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

python+selenium:解决上传文件&amp;lt;input type='file'&amp;gt;标签属性被css的visibility隐藏导致无法定位元素的问题

要想上传文件,需要找到在HTML中<inputtype="file" />这个标签,有它就可以利用send_keys上传文件,不过这里的<input>元素被隐藏了,导致一直定位不到input html代码如下,注意visibility:hidden,表示这个input元素被隐藏了,要想定位它必须先把隐藏属性去掉 一般控制元素显示或...

HTML控件篇 -- input

1. 取消input提示框及自动填充: <input type="text" autocomplete="off" /> 处理chrome下自动填充黄底样式问题: /*input样式特殊处理*/input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {-webkit-...

js---通配符选择器

原味转自:http://blog.sina.com.cn/s/blog_6e001be701017kaz.html 1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']");//id属性以code结束的所有input标签 $("input[id*=...

002输入子系统驱动

输入子系统概念介绍(第十三课/第一节) 回顾第三个驱动程序(中断方式的按键驱动程序)和测试程序,发现有一些缺点:这个驱动程序没办法用在别人写的现成的应用程序上(比如:QT),因为别人写的应用程序肯定不会来打开你这个"/dev/third_chrdev"。别人打开的是一些现成的设备(比如:/dev/tty),甚至别人都不打开设备,而是直接调用 scanf()...

CentOS下防御或减轻DDoS攻击方法(转)

查看攻击IP 首先使用以下代码,找出攻击者IP netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n 将会得出类似如下的结果: 1 114.226.9.132 1 174.129.237.157 1 58.60.118.142 1 Address 1 s...

jquery参考手册

jQuery 选择器 选择器 实例 选取 * $("*") 所有元素 #id $("#lastname") 的元素 .class $(".intro") 的所有元素 .class,.class $(".intro,.demo") class 为 "intro" 或 "demo" 的所有元素 element $("p")...