用nuxt框架写的,内容写在nuxt组件里面
<template>
<div class="home-main-wrap">
<home-header/>
<nuxt/>
<home-footer/>
</div>
</template>
nuxt组件里面
<template>
<div id="vue-app">
//其他div内容
<div class="anchorWrap" id="anchorWrap">
<a-anchor
:offsetTop='100'
:target-offset="targetOffset"
class="pc-container"
@click="handleClick"
:affix="false"
:getContainer="getDom"
>
<a-anchor-link
v-for="(item, index) in anchorData"
:key="index"
:href="item.href"
:title="item.title"
:class="currentHref == item.href ? 'anchor-active' : ''"
></a-anchor-link>
</a-anchor>
</div>
//其他div内容
</div>
<template>
//getDom:
getDom:()=> {
return document.getElementById('vue-app');
},
这个组件的API除了:target-offset="targetOffset"和@click="handleClick"其他都不起作用,getDom用console.log打印出来得知这个函数是有执行的并且执行了4次,但是指定了容器依旧没有效果QAQ