我有两个异步组件
const anchorPoint = defineAsyncComponent(() => import('@/layout/components/anchorPoint/anchorPoint.vue'));
const fieldset = defineAsyncComponent(() => import('@/components/fieldset/fieldset.vue'));
第一个是锚点组件,我需要在他内部去判断 fieldset
中一些元素的滚动情况,
所以使用了 querySelectorAll
,但我发现由于异步的原因我无法获取到 DOM
onMounted(async () => {
await nextTick();
const NodeList = document.body.querySelectorAll(props.anchor);
console.log('0000000000000', NodeList); // 为空
// ......
renderAnchor(NodeList);
});
请问我该如何解决这个问题?