我有一个标题,子标题,图标和按钮在我的v-card。我的目标是把我的创建按钮的权利,但我似乎不能做到这一点。
<template>
<v-row class="pl-5">
<v-card class="pl-5" elevation="0">
<v-card-title>
<v-icon left x-large color="primary">{{ icon }}</v-icon>
<span class="font-weight-bold">{{ title }}</span>
</v-card-title>
<v-card-subtitle> Subheader </v-card-subtitle>
<v-spacer></v-spacer>
<router-link v-if="type == 'index'" :to="`/${name.toLowerCase().replace(' ', '-')}/create`">
<v-btn outlined class="blue--text mt-5 mr-8">
<span>Create</span>
</v-btn>
</router-link>
</v-card>
</v-row>
</template>
<script>
export default {
props: {
icon: String,
name: String,
title: String,
subtitle: String,
type: String
},
components: {}
}
</script>
<style scoped></style>
如果我在<v-card-subtitle>
中移动<router-link>
我明白了
如果我在<v-card-title>
中移动<router-link>
我明白了
有人能给予我一下吗?
小提琴https://jsfiddle.net/bheng/h2u870dv/
如果我这样做:
<v-row class="pl-5">
<v-card-title>
<span class="material-icons">
favorite_border
</span>
<p class="font-weight-bold">TITLE</p>
<p class="caption">ST</p>
</v-card-title>
<v-spacer></v-spacer>
<v-btn>Create</v-btn>
</v-row>
我明白
按钮似乎在我想要的位置,但标题和副标题错位非常严重。我现在卡住了。
3条答案
按热度按时间kcugc4gi1#
您可以在v-row中添加div或v-col,并使用css以您想要的方式对齐项目:
whhtz7ly2#
你的问题是你把你的按钮放在你声明的
v-card
里面来设置标题的样式。而这张卡片只是一个正方形的盒子,因为你没有指定任何宽度。如果你设置elevation=“1”,你可以清楚地看到这一点。只要把你的按钮放在v-card外面,
v-spacer
就可以工作了。或者,你也可以把v-card
的宽度设置为100%。顺便说一下,你也可以在你的v-btn
中使用to
prop ,所以没有必要有一个v-router-link
。检查我做的这个codesandbox:https://codesandbox.io/s/stack-71444864-v-spacer-example-0tx24n?file=/src/components/Example.vue
更新:v-cols和带断点条件的自定义CSS
我看到你有兴趣学习如何使用vuetify's grid进行设计。使用v-cols和断点条件的好处是,你可以在不同的视口中更好地控制你的设计。就像在移动的视图中一样。这就是我的做法。
首先,我将网格分成2列,一列用于标题,一列用于按钮,在
cols
视图(以前称为xs
(超小))中,我将它们的大小设置为12列,在sm
(小)和更高的视图中,我将它们的大小设置为6列。标题栏没有变化,在底部栏,我使用类
d-flex justify-end
将按钮全部向右移动,align-center
将按钮垂直居中在v-row
的中间。然后,我使用断点条件来激活按钮的
block
属性,并根据当前视口对整个v行应用填充。0vvn1miw3#
你正在使用Vuetify的权利?然后更容易,只需添加按钮在v-card-title标签与绝对右上角attrs.然后v-btn也允许:到(https://v2.vuetifyjs.com/en/api/v-btn/#props)