应用程序.vue有一个transition标签,可以淡出和淡入页面.

<router-view v-slot="{ Component }">
   <transition name="fade" mode="out-in" appear>
      <component :is="Component"></component>
   </transition>
</router-view>

这一页.vue文件的 struct 很简单,但它也有一个基本的sliderjs组件,它会抛出错误<Transition> renders non-element root node that cannot be animated..如果删除transition标记,一切正常.

<div v-if="page.isReady">
   <swiper>
      <swiper-slide>Slide 1</swiper-slide>
      <swiper-slide>Slide 2</swiper-slide>
      <swiper-slide>Slide 3</swiper-slide>
   </swiper>
</div>

https://swiperjs.com/vue/

该文件还包含以下内容:

import { Swiper, SwiperSlide } from 'swiper/vue';
import 'swiper/swiper.scss';

export default {
  components: {
    Swiper,
    SwiperSlide,
  },
  
  setup () {
    return {
      page: usePage()
    }
  }
}

有什么办法可以纠正这个错误吗?谢谢你的建议!

推荐答案

<template>
  <div></div>
  <div>~someone~</div>
</template>

<template>
  <div>
    <div></div>
    ~someone~
  </div>
</template>

如果不在"模板"标记内使用"div"标记,则会出现相同的错误.(顺便说一句,可以使用div标签以外的其他标签)

Vue.js相关问答推荐

Vue ChildComponent (GrandchildComponent) 应该更新 ParentComponent 的列表

Vuetify 3 v-radio-group 将模型设置为 null

将 v-calendar 与以时间和日期格式出现的事件一起使用

有没有办法将react 键作为值传递给由 v-for 创建的 v-model

vue3 + pinia:如何从?store 中获取一个值

为什么将 name 与 router-link 一起使用比仅使用 to 与 path 更好?

我可以在打印 HTML 页面时使用作用域 CSS 吗? (使用 Laravel 和 Vue.js)

有没有办法初始化一个保留初始 HTML 的 Vue 对象

Vue.js 开发工具未显示

在 vue.js 中获取当前时间和日期

单击链接会更改 url,但不会更改页面上的内容/数据

如何使用 vuejs 从 SPA 访问 /storage -laravel- 中的图像

VS代码中的红点是什么意思

使用 vue-router 的默认子路由

在找不到图像源时设置替代图像

将 SignalR 与 Vue.js 和 Vuex 集成

找不到模块 'babel-core' 但已安装 @babel/core

将 ref 的内容从子组件传递到另一个 VueJS 子组件

Vuetify RTL 风格

Vuejs 不会在 HTML 表格元素中呈现组件