解决了input中的清空按钮失效(由于键盘弹起导致的按钮失效)
1.npm install fastclick
2. import FastClick from ‘fastclick’
3. 在页面中引用
1用在body上:
FastClick.attach(document.body)
2.用在某个元素上 FastClick.attach(document.getElementById(“appointment”));//取消苹果手机延迟click事件
fastClick会导致隐藏的input的点击事件失效。
故input不隐藏,给个css:
position: absolute;
top: 0;
width: 56px;//代替input框显示的那个button的宽度
opacity: 0;
列如:添加附件
<div class="pb-10 relative">
<span class="text-active" @click="addEnclosure(item,index)">添加附件</span>
<input type="file" :id="`files-${index}`" :ref="`files-${index}`" multiple
@change="handleFilesUpload(item,index)" class="add-enclosure-input-class"
:accept="acceptList.join(',')"/>
</div>
addEnclosure(item, index) {//添加附件
this.$nextTick(()=>{
document.getElementById(`files-${index}`).click();//模拟点击input
})
},
.add-enclosure-input-class{
position: absolute;
top: 0;
width: 56px;
opacity: 0;
}