1.vue3使用a-anchor锚点快速找到信息内容在当前页面的位置
代码如下(示例):
<template>
<div class="agreement">
<div class="pane">
<div id="container" class="content">
<div id="basic">
<h1>Basic</h1>
<div style="height: 600px"></div>
</div>
<div id="line-less">
<h1>LineLess Mode</h1>
<div style="height: 600px"></div>
</div>
<div id="Lake">
<h1>StreamLake</h1>
<div style="height: 600px"></div>
</div>
</div>
<div class="title">
<a-anchor line-less :change-hash="false" scroll-container="#container">
<a-anchor-link href="#basic">Basic</a-anchor-link>
<a-anchor-link href="#line-less">LineLess Mode</a-anchor-link>
<a-anchor-link href="#Lake">StreamLake</a-anchor-link>
</a-anchor>
</div>
</div>
</div>
</template>
<script lang='ts' setup>
</script>
<style lang='scss' scoped>
.agreement {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
.pane {
display: flex;
justify-content: space-between;
margin: $margin;
padding: $padding;
height: calc(100% - 60px);
background: $color-bg-box;
.content {
width: calc(100% - 250px - 32px);
padding-right: 16px;
height: 100%;
overflow-y: auto;
border-right: 1px solid $color-border;
}
.title {
width: 250px;
padding-left: 16px;
}
}
}
</style>
2.注意!注意!注意!
change-hash 设置为false
scroll-container 要指定滚动容器 scroll-container="#container"
<div id="container" class="content">
3.效果图
官网:(https://arco.design/vue/component/anchor)