【发布时间】:2018-07-10 01:21:26
【问题描述】:
我正在尝试使用 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)
})
路由器/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>© 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.vue 与 App.vue 完全一样,只是 span 工具提示中的文本不同(我尝试过更激进的更改以及可见性)。
问题/问题:
- 为什么没有显示AccountsListView.vue,而我在访问
/accounts时看到了App.vue? - 我重用布局组件的方法是否正确,或者我是在重新发明轮子,还有其他“正确”的方法吗?
【问题讨论】:
标签: javascript vue.js vue-router vuetify.js