如何在页面中将索引栏放在导航栏下 #12129
liujinwang223
started this conversation in
General
如何在页面中将索引栏放在导航栏下
#12129
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
打扰一下我想提个问题,我当前有一个场景就是关于选择人员列表的页面。上方有一个导航栏,下方是那个员工列表,当我点击锚点的时候如何向下做一个margin的距离将导航栏的距离隔出来,这是我的代码请大佬指点一二,
template :
<van-nav-bar
title="选择审批人"
left-arrow
@click-left="onClickLeft"
/>
<van-search
v-model="value"
show-action
placeholder="请输入中文名或工号"
@search="onSearch"
/>
<van-index-bar :index-list="indexList" ref="indexBarTo" @select="onIndexSelect" :offset-bottom="90" >
方法如下:
//跳转到索引
const onIndexSelect = (index:any) => {
console.log(index);
// indexBarTo.value?.scrollTo(index);
const targetElement = document.getElementById(
md${index}
);console.log(targetElement)
if (targetElement) {
// 跳转到锚点位置,并向下预留导航栏高度(假设导航栏高度为 60px)
const offset = targetElement.offsetTop -60;
console.log(offset)
indexBarTo.value?.scrollTo(offset);
}
}
Beta Was this translation helpful? Give feedback.
All reactions