vuetify.js - 如何使用 Vuetify 将 v-card 放在页面中心
问题描述
我的目标是在页面中心放置一张 v-card。我正在使用 Vuetify。此代码应该可以工作,但不能:
<template>
<v-container fill-height>
<v-row align="center" justify="center">
<v-col>
<v-card flat color="grey" class="lighten-3" max-width="500px">
<v-card-title>{{ title }}</v-card-title>
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions>
<slot name="actions"></slot>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
我究竟做错了什么?请帮忙。
更多上下文:我在多个地方将它用作 BaseComponent。这是我的例子:
<template>
<div>
<BaseInfoMenu title="Title">
<template slot="content">
//content
</template>
<v-btn slot="actions">...</v-btn
</div>
//Some invisible divs
</template>
解决方案
我解决了。BaseInfoMenu 组件周围的 div 是问题所在。我删除了它。此外 align="center" 必须进入 v-col 或删除 v-col。功能代码如下所示:
<template>
<v-container fill-height>
<v-row justify="center" align="center"> //No v-col
<v-card flat color="grey" class="lighten-3" max-width="500px">
<v-card-title>{{ title }}</v-card-title>
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions>
<slot name="actions"></slot>
</v-card-actions>
</v-card>
</v-row>
</v-container>
</template>
上下文将是
<template>
<BaseInfoMenu title="Title"> //no div
<template slot="content">
//content
</template>
<v-btn slot="actions">...</v-btn
//Some invisible divs
</template>
推荐阅读
- spring - 如何使用 Spring Framework 构建事件通知
- openid - OpenID Connect Claims 有什么好处?
- java - Java二次继承返回空值
- database - 将数据从mariadb迁移到oracle数据库的有效方法是什么
- android - 为什么我只能正确获得第一个也是最后一个适配器位置的数据库 ID?
- d3.js - 如何将一组新数据添加到 D3 层次结构?
- javascript - 使用全局变量时函数运行不正常
- java - 在 Tomcat 嵌入服务器(Heroku Deploy)Spring MVC 上上传和获取图像
- javascript - 按 DateTime 字段对 JS 对象数组进行排序和分组
- maven - 如果 nexus 关闭,请使用本地 .m2 文件夹中的依赖项