diff --git a/examples/routers/anchor.vue b/examples/routers/anchor.vue index f99e3fb..6639ee9 100644 --- a/examples/routers/anchor.vue +++ b/examples/routers/anchor.vue @@ -3,7 +3,7 @@ <div class="link-wrapper"> <Button @click="changeCon">修改为Window</Button> <Button @click="andLink">添加一个连接</Button> - <Anchor @on-change="handleChange" @on-select="handleSelect" :style="{right: '100px'}" :affix="true" :offset-top="30" :container="scrollCon" show-ink-in-fixed> + <Anchor :bounds="100" @on-change="handleChange" @on-select="handleSelect" :style="{right: '100px'}" :affix="true" :offset-top="30" :scroll-offset="100" :container="scrollCon" show-ink-in-fixed> <AnchorLink v-if="(link - 1) % 30 === 0" v-for="link in 300" :key="`link${link}`" :href="`#title-${link}`" :title="`title-${link}`"> <AnchorLink v-if="link === 61" href="#title-child-69" title="title-child-69"/> </AnchorLink> diff --git a/src/components/anchor/anchor.vue b/src/components/anchor/anchor.vue index 52072ad..214f9c7 100644 --- a/src/components/anchor/anchor.vue +++ b/src/components/anchor/anchor.vue @@ -53,6 +53,10 @@ export default { showInkInFixed: { type: Boolean, default: false + }, + scrollOffset: { + type: Number, + default: 0 } }, computed: { @@ -92,7 +96,7 @@ export default { handleScrollTo () { const anchor = document.getElementById(this.currentId); if (!anchor) return; - const offsetTop = anchor.offsetTop - this.wrapperTop; + const offsetTop = anchor.offsetTop - this.wrapperTop - this.scrollOffset; this.animating = true; scrollTop(this.scrollContainer, this.scrollElement.scrollTop, offsetTop, 600, () => { this.animating = false; -- libgit2 0.21.4