Skip to content

Anchor - 锚点

基础用法

<ja-anchor>
  <ja-anchor-link href="#基础用法" title="基础用法"></ja-anchor-link>
  <ja-anchor-link href="#水平模式" title="水平模式"></ja-anchor-link>
</ja-anchor>

水平模式

<ja-anchor direction="horizontal">
  <ja-anchor-link href="#基础用法" title="基础用法"></ja-anchor-link>
  <ja-anchor-link href="#水平模式" title="水平模式"></ja-anchor-link>
</ja-anchor>

Anchor API​

Anchor Attributes

参数说明类型可选值默认值
container绑定锚点组件的容器元素string / HTMLElement / Window --
direction锚点组件的显示模式stringhorizontal / verticalvertical
duration滚动到指定锚点时,动画过渡时间number-300

Anchor Events

事件名说明类型
change锚点切换时触发(href: string) => void
click点击锚点时触发(e: MouseEvent, href?: string) => void

Anchor Methods

方法名说明参数
scrollTo滚动到指定锚点(href: string) => void