<template>
...
<Anchor :items="goodTypeList" :getContainer="getContainerFn"></Anchor>
<div id="goodsShowBox">
<div v-for="item in goodsList" :id="item.id" :key="item.id" class="goodsInfoBox">
...
</div>
</div>
...
</template>
<script setup>
import { Anchor } from 'ant-design-vue';
const goodTypeList = ref([
{key: 1,href: '#1',title: 'a'},
{key: 2,href: '#2',title: 'b'},
{key: 3,href: '#3',title: 'c'},
{key: 4,href: '#4',title: 'd'}
]);
const goodsList = ref([
{id: '1', ...},
{id: '2', ...},
{id: '3', ...},
{id: '4', ...}
])
function getContainerFn() {
return document.querySelector('#goodsShowBox');
}
</script>
<style>
...
</style>
参考