首页 > 解决方案 > Nativescript vue slot 默认组件问题

问题描述

我试图用 nativescript-vue 创建一个移动应用程序,但在使用插槽时遇到了默认组件渲染的问题。所以有带有 Frame 和内部插槽的 App.vue。

<Frame ~mainContent>
  <slot name="mainContent"></slot>
</Frame>

还有一个带有可用组件的路由器:

import EducationPlacesList from './components/EducationPlacesList'
import PersonalProfile from './components/PersonalProfile'

const router = {
   EducationPlacesList: EducationPlacesList,
   PersonalProfile: PersonalProfile
}

由于本机脚本 vue 目前不支持 Vue 路由器,因此有一个通过手动路由导航的解决方案,它工作得很好。我有一个带有标签的侧边栏,ontap还有一个 this.$navigateTo(this.$router[to], options)- 通过点击可以完美地重定向我。

但是,如果我启动我的应用程序并且不点击任何链接,则会出现预期的空白空间。因为在导航到某个页面之前插槽是空的。我想知道,有没有一个好的做法,如何设置这个插槽的默认组件。

标签: javascriptvue.jsmobilenativescriptnativescript-vue

解决方案


推荐阅读