nuxt -node.appendchild:无法在评论中添加孩子

发布于 2025-02-08 18:57:57 字数 1652 浏览 2 评论 0原文

在生产模式下部署我的NUXT应用到firebase时,每当我尝试导航到主页以外的任何页面时,都会出现以下错误:

Node.appendChild: Cannot add children to a Comment

我发现当我在索引中评论home-slider component时。

index.vue template

<template>
  <article>
    <div v-if="slides && slides.length > 0">
      <section id="banner">
        <div class="container">
          <client-only>
            <home-slider :slides="slides"></home-slider>
          </client-only>
        </div>
      </section>
    </div>

    [...unrelated html]
  </article>
</template>

homeslider.vue模板

<template>
  <div>
    <Splide id="home-slider" :options="options">
      <SplideSlide v-for="slide in slides" :key="slide.id">
        <a :href="slide.enlace" class="slide">
          <div
            class="slide-content"
            v-html="slide.contenido"
            v-show="slide.contenido"
          ></div>
          <div class="img-container">
            <img :src="slide.imagen" :alt="slide.titulo" />
          </div>
        </a>
      </SplideSlide>
    </Splide>
  </div>
</template>

删除client> client-forly组件也将其修复,但是速度无法正确呈现。

根据 this github问题,这可能与无效的html有关,但是我看不到是什么原因引起的,我可以看到,当我导航到任何路线时,它首先呈现索引。

我在另一个页面上还有另一个挥发器,当我导航到主页时,似乎并没有给我任何问题。

When deploying my Nuxt app in production mode to Firebase I get the following error whenever I attempt to navigate to any page other than the homepage:

Node.appendChild: Cannot add children to a Comment

I've found that when I comment my home-slider component in index.vue I no longer get this error, however commenting everything inside the home-slider while still leaving the component call throws the error.

index.vue template

<template>
  <article>
    <div v-if="slides && slides.length > 0">
      <section id="banner">
        <div class="container">
          <client-only>
            <home-slider :slides="slides"></home-slider>
          </client-only>
        </div>
      </section>
    </div>

    [...unrelated html]
  </article>
</template>

HomeSlider.vue template

<template>
  <div>
    <Splide id="home-slider" :options="options">
      <SplideSlide v-for="slide in slides" :key="slide.id">
        <a :href="slide.enlace" class="slide">
          <div
            class="slide-content"
            v-html="slide.contenido"
            v-show="slide.contenido"
          ></div>
          <div class="img-container">
            <img :src="slide.imagen" :alt="slide.titulo" />
          </div>
        </a>
      </SplideSlide>
    </Splide>
  </div>
</template>

Removing the client-only component also fixes it, but then splide won't render correctly.

According to this github issue this could be related to invalid HTML, however I can't see what's causing it, I can see that when I navigate to any route it first renders index.vue, then it tries to render the other page, is there a way to prevent other pages from rendering?

I have another Splide in a different page which doesn't seem to be giving me any issues when I navigate to the homepage.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文