【发布时间】:2021-06-25 11:28:01
【问题描述】:
我遇到了一些奇怪的问题。 Vuetify 在我的 nuxt.js 项目中的功能有限。
首先这是我的默认布局:
<div>
<NavBar />
<Nuxt />
</div>
</template>
并且 NavBar 组件覆盖了页面。
但是,如果我从 <v-app-bar app flat> 中删除 app 属性,问题就会消失,但 NavBar 将不会始终位于页面顶部。
详情见截图:
默认视图:
在lorem 上使用margin-top: 100px; 查看
NavBar组件的代码:
<template>
<nav>
<v-app-bar app flat>
<v-app-bar-nav-icon
x-large
class="grey--text"
@click="drawer = !drawer"
/>
<v-spacer />
<v-toolbar-title>
<a href="/">LOGO</a>
</v-toolbar-title>
<v-spacer />
<v-menu offset-y>
<template #activator="{ on, attrs }">
<v-btn text v-bind="attrs" v-on="on">
<!-- <v-icon>expand_more</v-icon> -->
Dropdown menu
</v-btn>
</template>
<v-list>
<v-list-item v-for="contact in contacts" :key="contact.i">
<v-list-item-action>
<a :href="contact.link">
<v-icon>
{{ contact.icon }}
</v-icon>
</a>
</v-list-item-action>
<v-list-item-content>
<a :href="contact.link">
<v-list-item-title>
{{ contact.name }}
</v-list-item-title></a
>
</v-list-item-content>
</v-list-item>
</v-list>
</v-menu>
</v-app-bar>
<v-navigation-drawer v-model="drawer" bottom temporary app>
<v-list>
<v-list-item
v-for="link in links"
:key="link.i"
router
:to="link.route"
@click="refresh"
>
<v-list-item-action>
<v-icon>{{ link.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
<span> {{ link.name }} </span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
</nav>
</template>
<script>
export default {
data() {
return {
drawer: false,
}
},
computed: {
links() {
return this.$store.state.routes
},
contacts() {
return this.$store.state.contacts
},
},
methods: {
refresh() {
if (this.drawer) {
this.drawer = !this.drawer
}
},
},
}
</script>
<style></style>
如您所见,NavBar 覆盖了部分内容。
另一个问题是class="mt-5 pt-5" 或任何其他关于margin 或padding 的类都不起作用。 class="d-flex" 也不行。
正如您在屏幕截图中看到的那样,有一个 class="ml-5 pl-5 d-flex" 但没有剩余边距,没有剩余填充,并且容器不是弹性的。
然而
:class="{
'tiny': $vuetify.breakpoint.smAndDown,
'large': $vuetify.breakpoint.mdAndUp,
}"
和
<style>
.tiny {
font-size: 1rem;
color: red;
}
.large {
font-size: 2rem;
color: green;
}
</style>
确实有效。
我真的很困惑nuxt.js中的vuetify
【问题讨论】:
标签: vue.js nuxt.js vuetify.js