当前位置:网站首页>微信input组件添加清除图标,点击清空不生效
微信input组件添加清除图标,点击清空不生效
2022-07-27 03:20:00 【console.log('D')】
微信小程序中使用input组件,点击上面的清空图标不生效问题
问题原因:在真机调试中,因为微信小程序中input组件的层级在聚焦时会最高,会覆盖清空图标,所以点击不生效,在pc开发者工具中是不存在问题的
解决方法:
1.设置 input 的 padding-right 大于图标的宽度。
2.使用uview-UI中的input组件,修改input组件的深度样式,不要试图将清空图标放在input组件的上面,图标使用 cover-view 和 cover-image 组件也不可以。
代码实现(方法1):
html:
<view class="content-brandSearch">
<input v-model="brandName" class="brandSearch-input" type="text"/>
<view view v-if="brandName" class="brandSearch-icon" @click="clear(0)">
<img src="@img/close.png" alt=""/>
</view>
</view>css:
.content-brandSearch {
position: relative;
.brandSearch-input {
/******加这行代码,超过图标的宽度*********/
padding-right: rpx(35);
/**************************************/
width: rpx(351);
height: rpx(36);
background: #f6f7f9;
border-radius: rpx(24.5);
}
.brandSearch-icon {
width: rpx(15);
height: rpx(15);
position: absolute;
right: rpx(26);
top: rpx(26);
img {
width: 100%;
height: 100%;
}
}
}js:
data() {
return {
brandName: "",
factoryName: "",
};
},
methods:{
//input上的x
clear(type) {
if (type == 0) {
this.brandName = "";
} else {
this.factoryName = "";
}
},
}边栏推荐
- 技术分享 | 需要小心配置的 gtid_mode
- H. 265 web player easyplayer's method of opening video to the public
- 3381. 手机键盘(清华大学考研机试题)
- Internet of things smart home project - Smart bedroom
- 【MySQL系列】MySQL索引事务
- Use tag tag in golang structure
- leetcode每日一题:数组的相对排序
- 【小样本分割】MSANet: Multi-Similarity and Attention Guidance for Boosting Few-Shot Segmentation
- Subject 3: Jinan Zhangqiu line 3
- 【obs】动态码率:码率估算
猜你喜欢

JMeter interface test (login, registration)

Golang发送邮件库email

Session&Cookie&token

356 pages, 140000 words, weak current intelligent system of high-end commercial office complex, 2022 Edition

MySQL: understand the basic knowledge of MySQL and computer

list模拟实现

Restful fast request 2022.2.2 release, supporting batch export of documents

Introduction to JVM principle

科目三: 济南章丘二号线

【小样本分割】MSANet: Multi-Similarity and Attention Guidance for Boosting Few-Shot Segmentation
随机推荐
The real digital retail should have richer connotation and significance
Read and understand | how data center supports enterprise digital operation
Interview question 02.05. sum of linked list
BigDecimal踩坑总结&最佳实践
Elastic开源社区:开发者招募
Principle of bean validation --07
【LeetCode】Day104-无重叠区间
Parallel desktop startup virtual machine "operation failed" problem solution
leetcode每日一题:数组的相对排序
C. Cypher
链表内指定区间反转
【小样本分割】MSANet: Multi-Similarity and Attention Guidance for Boosting Few-Shot Segmentation
C#怎么实现给Word每一页设置不同文字水印
真正意义上的数字零售应当具有更加丰富的内涵和意义
面试题 16.05. 阶乘尾数
Want to get the Apache official domain name mailbox? Exclusive interview with Apache linkis five new committers to tell you how to do it
记一次TCP丢包带来的重大性能问题
STM32CubeMX学习笔记(41)——ETH接口+LwIP协议栈使用(DHCP)
Ribbon负载均衡策略与配置、Ribbon的懒加载和饥饿加载
三种常见的移动底盘运动学模型分析