vue项目中有一个需要实现说明书的功能,左侧有目录,右侧是全部的文档,点击左侧目录,可以直接定位到文档相应位置,想到了html原生代码herf跳转
<a href="#m1"> 通过id获取锚点</a>
<div style="width:100%;height:1000px"></div>
<div style=" height:100px; width:100%; background: red; id="m1"> 通过id获取锚点</div>
vue可用anchor组件实现
<template>
<div >
<div class="title"><h1>Vue-Lov-Anchor</h1></div>
<!-- <div class="anchor-horizontal">
<div class="anchor">
<lov-anchor targetid="anchorid" horizontal>
<lov-anchor-link v-for="id in 5" :key="id" :href="'#box'+id" :title="'anchorlink'+id"></lov-anchor-link>
<lov-anchor-link href="#box6">
<template slot="slot">
<span style="color:red"> slot-link6</span>
</template>