当前位置:网站首页>微信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 = "";
}
},
}边栏推荐
猜你喜欢

零基础小白也能懂的 Redis 数据库,手把手教你易学易用!

Is VR panoramic production a single weapon in the home decoration industry? Why is this?

【比赛参考】PyTorch常用代码段以及操作合集

452页13万字现代智慧乡镇雪亮工程整体解决方案2022版

11.zuul路由网关

Subject 3: Jinan Zhangqiu line 3

Redis (IX) - redis distributed lock

VR全景人淘金“小心机”(上)

《MySQL》认识MySQL与计算机基础知识

2022 retraining question bank and answers for main principals of hazardous chemical business units
随机推荐
CloudCompare&PCL 匹配点中值(或标准差)距离抑制
The 100th of the commercial anti counterfeiting series - boring systems and management processes can really be thrown into the trash can - by the way, analyze a dozen useless unity game self-test proj
Leetcode:433. minimal genetic change
Which securities company has the lowest handling charge? Is it safe to open an account on your mobile phone
C. Cypher
从根到叶的二进制数之和
Parallel desktop startup virtual machine "operation failed" problem solution
Analyze CAS written by CSDN boss, re-entry lock, unfair lock
webpack打包vue项目添加混淆方式,解决缓存问题
Parallels Desktop启动虚拟机“操作失败”问题解决
真正意义上的数字零售应当具有更加丰富的内涵和意义
2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units
leetcode每日一题:数组的相对排序
C#怎么实现给Word每一页设置不同文字水印
SkyWalking分布式系统应用程序性能监控工具-中
商业打假系列之第一百之--无聊的制度和管理流程真的可以扔进垃圾桶-顺便分析十几个无用的Unity游戏自检项目
三种常见的移动底盘运动学模型分析
ffmpeg合并视频功能
括号的最大嵌套深度
【OBS】circlebuf