我正在尝试使用vuetify实现一个支持布局的Vue应用程序。 Vue的新手很可能是一些新手的错误。我的app结构如下:
的 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)
})
路由器/ 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
})
应用/ index.js
export { default as routes } from './routes'
export { default as vuex } from './vuex'
export { default as App } from './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>© 2018</span>
</v-footer>
</v-app>
</template>
<script>
export default {
data: () => ({
drawer: null,
dialog: false
}),
props: {
source: String
}
}
</script>
应用/帐户/ 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.vue 与 App.vue 绝对相同,但span工具提示中的文字不同(我试过更激进)变化以及能见度) 问题/问题:
/accounts
时,我看到 App.vue ?答案 0 :(得分:1)
A1。
检查components.AccountsListView
中的app/accounts/routes.js
是否为空。当路由组件为空时,Vue不会抛出错误。如果有效,请检查您的App.vue
是否<router-view />
。
A2。
我认为通过提供内容插槽重用布局是有效的。但我会直接在App.vue
中定义布局,并使用<router-view />
作为<slot />
。然后在routes
中,我将定义{ path: '/', component: Base }
或{ path: '/', component: Welcome }
。