The error message suggests that the this.$refs.container is not a valid DOM node.

To fix this issue, make sure that this.$refs.container refers to a valid DOM element. You can check if this.$refs.container is defined and if it is a DOM element before using it in the observe method.

Here's an example of how you can validate this.$refs.container:

const container = this.$refs.container;
if (container instanceof Element) {
  const observer = new MutationObserver(() => {
    this.scrollToBottom();
  });
  observer.observe(container, {
    childList: true
  });
} else {
  console.error('Invalid DOM element: this.$refs.container');
}

By adding this check, you can prevent the observe method from being called with an invalid DOM node

const container = this$refscontainer;			const observer = new MutationObserver = 				thisscrollToBottom;			;			childList true 表示要观察子节点的增加或删除。			observerobservecontainer 				childList true			;Failed to

原文地址: http://www.cveoy.top/t/topic/iCcs 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录