vue js布局中的不正确组件

vue js incorrect component in layout

我正在尝试使用 vuetify 实现一个支持布局的 Vue 应用程序。 Vue 的新手,所以很可能是新手犯的错误。我的应用程序结构如下:
main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuetify from 'vuetify'
import { App } from './app'
import router from './router'
import store from './store'
import('../node_modules/vuetify/dist/vuetify.min.css')

/* eslint-disable no-new */

console.log(router)

Vue.use(Vuetify)

new Vue({
  el: '#app',
  store,
  router,
  render: h => h(App)
})

router/index.js

import Vue from 'vue'
import Router from 'vue-router'
import routes from '../app/routes'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: routes
})

app/index.js

export { default as routes } from './routes'
export { default as vuex } from './vuex'
export { default as App } from './App'

app/App.vue

<template>
  <app-base-layout>
    <v-content slot="content">
      <v-container fluid="" fill-height="">
        <v-layout justify-center="" align-center="">
          <v-tooltip right="">
            <v-btn icon="" large="" :href="source" target="_blank" slot="activator">
              <v-icon large="">code</v-icon>
            </v-btn>
            <span>Source</span>
          </v-tooltip>
        </v-layout>
      </v-container>
    </v-content>
  </app-base-layout>
</template>

<script>
import AppBaseLayout from './AppBaseLayout'
export default {
  components: {
    AppBaseLayout
  },
  data: () => ({
  }),
  props: {
    source: String
  }
}
</script>

app/AppBaseLayout.vue(注意<slot name="content"></slot>

<template>
  <v-app id="inspire" dark="">
    <v-navigation-drawer
      clipped=""
      fixed=""
      v-model="drawer"
      app="">

      <v-list dense="">

        <v-list-tile :to="{path: '/', params: {id: 'test'}}">
          <v-list-tile-action>
            <v-icon>home</v-icon>
          </v-list-tile-action>
          <v-list-tile-content>
            <v-list-tile-title>Home</v-list-tile-title>
          </v-list-tile-content>
        </v-list-tile>

        <v-list-tile :to="{name: 'accountsListView', params: {id: 'add'}}">
          <v-list-tile-action>
            <v-icon>dashboard</v-icon>
          </v-list-tile-action>
          <v-list-tile-content>
            <v-list-tile-title>Tester</v-list-tile-title>
          </v-list-tile-content>
        </v-list-tile>

        <v-list-tile @click.stop="dialog = true">
          <v-dialog v-model="dialog" max-width="290">
            <v-card>
              <v-card-title class="headline">Use Google's location service?</v-card-title>
              <v-card-text>Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.</v-card-text>
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn color="green darken-1" flat="flat" @click.native="dialog = false">Disagree</v-btn>
                <v-btn color="green darken-1" flat="flat" @click.native="dialog = false">Agree</v-btn>
              </v-card-actions>
            </v-card>
          </v-dialog>
          <v-list-tile-action>
            <v-icon>settings</v-icon>
          </v-list-tile-action>
          <v-list-tile-content>
            <v-list-tile-title>Settings</v-list-tile-title>
          </v-list-tile-content>
        </v-list-tile>
      </v-list>
    </v-navigation-drawer>
    <v-toolbar app="" fixed="" clipped-left="">
      <v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
      <v-toolbar-title>Lost Memories</v-toolbar-title>
    </v-toolbar>

    <slot name="content"></slot>

    <v-footer app="" fixed="">
      <span>&copy; 2018</span>
    </v-footer>
  </v-app>
</template>

<script>
export default {
  data: () => ({
    drawer: null,
    dialog: false
  }),
  props: {
    source: String
  }
}
</script>

app/accounts/routes.js

import * as components from './components'

export default [
  {
    path: '/accounts',
    component: components.AccountsListView,
    name: 'accountsListView'
  },
  {
    path: '/accounts/create',
    component: components.CreateEditAccounts,
    name: 'createAccounts'
  },
  {
    path: '/accounts/edit',
    component: components.CreateEditAccounts,
    name: 'editAccounts'
  }
]

我的 app/accounts/components/AccountsListView.vueApp.vue 完全相同,除了跨度工具提示中的文本是不同(我也尝试了更彻底的改变以提高可见度)。
Questions/problems:

  1. 为什么不显示AccountsListView.vue,访问[=17=时看到App.vue ]?
  2. 我重用布局组件的方法是否完全正确,或者我是在重新发明轮子,还有其他 "proper" 方法吗?

A1.

检查 app/accounts/routes.js 中的 components.AccountsListView 是否为空。当路由的组件为 null 时,Vue 不会抛出错误。如果有效,请检查您的 App.vue 是否有 <router-view />

A2.

我认为通过提供内容插槽来重用布局是有效的。但是我会直接在App.vue定义布局,用<router-view />作为<slot />。然后在routes中,我会定义一个{ path: '/', component: Base }{ path: '/', component: Welcome }.