当前位置: 代码网 > it编程>前端脚本>Vue.js > vue arco.design锚点Anchor使用方式

vue arco.design锚点Anchor使用方式

2024年05月26日 Vue.js 我要评论
1.vue3使用a-anchor锚点快速找到信息内容在当前页面的位置代码如下(示例):<template> <div class="agreement"> <di

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" rel="external nofollow" >basic</a-anchor-link>
          <a-anchor-link href="#line-less" rel="external nofollow" >lineless mode</a-anchor-link>
          <a-anchor-link href="#lake" rel="external nofollow" >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)

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com