当前位置:网站首页>el-Select 选择器 底部固定
el-Select 选择器 底部固定
2022-08-04 04:43:00 【西小贝。】
需求:select 底部固定点击 滚动条直接到底部 展示input输入框
基本的引用element就不写了 直接写重点
HTML
<el-form-item label="名称:" prop="Name">
<el-select
ref="cascader" // 固定底部需要
v-model="sizeForm.parentTypeName"
class="select_mini"
placeholder="名称"
size="mini"
@visible-change="v => visibleChange(v, 'cascader', addCategory)"
>
<el-option
v-for="(item,index) in List"
:key="item.Code + index"
class="optionClass"
:label="item.TypeName"
:value="item.TypeCode"
>
<span class="check" />
<span style="margin-left: 8px">{
{ item.TypeName }}</span>
</el-option>
<div v-if="addCategoryValue" id="anchor">
<el-input v-model="sizeForm.parentName" placeholder="请输入内容"
size="mini" style="padding: 10px" />
<div style="text-align: right; padding-right: 10px">
<el-button class="btn_close" @click="addClose">取消</el-button>
<el-button type="primary" class="btn_save"
@click="addClickClose">确定</el-button>
</div>
</div>
</el-select>
</el-form-item>
Js
visibleChange(visible, refName, onClick) {
if (visible) {
const ref = this.$refs[refName]
let popper = ref.$refs.popper
if (popper.$el) popper = popper.$el
if (!Array.from(popper.children).some(v => v.className === 'el-cascader-menu__list')) {
const el = document.createElement('ul')
el.className = 'el-cascader-menu__list'
el.style = 'border-top: solid 1px #E4E7ED; padding:0;color: #4f7bff;cursor: pointer;'
el.innerHTML = `<li class="el-cascader-node" style="height:38px;line-height: 38px">
<span class="el-cascader-node__label">+新增大类</span>
</li>`
popper.appendChild(el)
el.onclick = () => {
this.addCategoryValue = true
setTimeout(() => {
document.querySelector('#anchor').scrollIntoView(true)
}, 100) // 因为我控制隐藏是用的v-if 所以第一次进来获取不到才加的延时
}
}
}
},
因为设计输入框是在select里面所以这样写 要是输入框放在外面可能需要在js里继续写样式 感兴趣的朋友可以尝试一下
到这里基本结束了 有问题留言
边栏推荐
猜你喜欢
随机推荐
技术解析|如何将 Pulsar 数据快速且无缝接入 Apache Doris
TL431的基本特性以及振荡电路
Bolb analysis of image processing (1)
基于gRPC编写golang简单C2远控
mysql索引笔记
Metaverse "Drummer" Unity: Crazy expansion, suspense still exists
FFmpeg —— 录制麦克风声音(附源码)
基于 SSE 实现服务端消息主动推送解决方案
manipulation of file contents
数据治理平台项目总结和分析
深度学习之 10 卷积神经网络3
路网编辑器技术预研
信息学奥赛一本通 1312:【例3.4】昆虫繁殖
FFmpeg —— 通过修改yuv,将视频转为黑白并输出(附源码)
Simple operation of the file system
Introduction and application of go module
How to open a CITIC Securities online account?is it safe?
2022软件测试面试题 最新字节跳动50道真题面试题 刷完已拿下15k 附讲解+答疑
【技巧】借助Sentinel实现请求的优先处理
XSS相关知识点