卡片 Vue 组件
除列表视图外,卡片是另一种整理和组织信息的好方法。卡片包含与一个主题相关的唯一数据,例如关于单个主题的照片、文本和链接。通常,卡片是通往更复杂和详细信息的入口。
Card Vue 组件表示卡片组件。
卡片组件
包含以下组件
f7-card
f7-card-header
f7-card-content
f7-card-footer
卡片属性
属性 | 类型 | 默认值 | 说明 |
---|---|---|---|
<f7-card> 属性 | |||
title | 字符串 | 卡片标题内容 | |
content | 字符串 | 卡片内容 | |
footer | 字符串 | 卡片页脚内容 | |
padding | 布尔值 | 真 | 添加卡片内容额外的内边距 |
轮廓 | 布尔值 | 假 | 创建卡片轮廓,带边框 |
outlineIos | 布尔值 | 假 | 创建 iOS 主题的卡片轮廓 |
outlineMd | 布尔值 | 假 | 创建 MD 主题的卡片轮廓 |
提升 | 布尔值 | 假 | 提升卡片,带阴影 |
标头分隔符 | 布尔值 | 假 | 添加卡片标头分隔符(边框) |
页脚分隔符 | 布尔值 | 假 | 添加卡片页脚分隔符(边框) |
可扩展 | 布尔值 | 假 | 启用可扩展卡片 |
可扩展-动画-宽度 | 布尔值 | 假 | 启用卡片内容宽度动画功能和响应式功能,但可能影响性能 |
可扩展-已打开 | 布尔值 | 假 | 布尔值参数,表示可扩展卡片是否已打开 |
动画 | 布尔值 | 真 | 指定可扩展卡片是否使用动画打开 |
在打开时隐藏导航条 | 布尔值 | 可隐藏可扩展卡片打开时的导航条。默认继承与之相同的 应用卡片参数。 | |
在打开时隐藏工具栏 | 布尔值 | 可隐藏可扩展卡片打开时的工具栏。默认继承与之相同的 应用卡片参数。 | |
滑动关闭 | 布尔值 | 允许通过滑动关闭可扩展卡片。默认继承与之相同的 应用卡片参数。 | |
背景 | 布尔值 | 启用可扩展卡片背景层。默认继承与之相同的 应用卡片参数。 | |
背景元素 | 字符串 | 允许指定自定义可扩展卡片背景元素。这应该是背景元素的 CSS 选择器,如:.card-backdrop.custom-backdrop | |
点击背景关闭 | 布尔值 | 启用此选项后,可通过点击背景关闭可扩展卡片。默认继承与之相同的 应用卡片参数。 | |
<f7-card-content> 属性 | |||
padding | 布尔值 | 真 | 添加额外的内边距 |
卡片事件
事件 | 说明 |
---|---|
<f7-card> 事件 | |
card:beforeopen | 可扩展卡片开始打开动画之前触发事件。当 event.detail.prevent 被调用时,它包含阻止卡片打开的函数 |
card:open | 可扩展卡片开始打开动画时触发事件 |
card:opened | 可扩展卡片完成打开动画后触发事件 |
card:close | 可扩展卡片开始关闭动画时触发事件 |
card:closed | 可扩展卡片完成关闭动画后触发事件 |
卡片插槽
<f7-card>
组件具有以下插槽
default
- 元素将作为卡片内容元素的子元素插入content
- 与default
相同header
- 元素将作为卡片标头元素的子元素插入footer
- 元素将作为卡片页脚元素的子元素插入
<f7-card>
<span slot="header">Header</span>
<span slot="content">Content</span>
<span slot="footer">Footer</span>
</f7-card>
渲染到
<div class="card">
<div class="card-header">
<span>Header</span>
</div>
<div class="card-content">
<span>Content</span>
</div>
<div class="card-footer">
<span>Footer</span>
</div>
</div>
卡片 v-model
可扩展卡片组件在 `expandable-opened` 属性上支持 `v-model`
<template>
<f7-page>
<f7-card expandable v-model:expandable-opened="isOpened">
...
</f7-card>
<p>Card is opened: {{ isOpened }}</p>
</f7-page>
</template>
<script>
export default {
data() {
return {
isOpened: false,
};
}
};
</script>
示例
cards.vue
<template>
<f7-page>
<f7-navbar title="Cards"></f7-navbar>
<f7-block>
<p>
Cards are a great way to contain and organize your information, especially when combined
with List Views. Cards can contain unique related data, like for example photos, text or
links about a particular subject. Cards are typically an entry point to more complex and
detailed information.
</p>
</f7-block>
<f7-block-title>Simple Cards</f7-block-title>
<f7-card
content="This is a simple card with plain text, but cards can also contain their own header, footer, list view, image, or any other element."
></f7-card>
<f7-card
title="Card header"
content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
footer="Card footer"
></f7-card>
<f7-card
content="Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet. Mauris aliquet magna justo. "
></f7-card>
<f7-block-title>Outline Cards</f7-block-title>
<f7-card
outline
content="This is a simple card with plain text, but cards can also contain their own header, footer, list view, image, or any other element."
></f7-card>
<f7-card
outline
title="Card header"
content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
footer="Card footer"
></f7-card>
<f7-card
outline
content="Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet. Mauris aliquet magna justo. "
></f7-card>
<f7-block-title>Outline With Dividers</f7-block-title>
<f7-card
outline
header-divider
footer-divider
title="Card header"
content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
footer="Card footer"
></f7-card>
<f7-block-title>Raised Cards</f7-block-title>
<f7-card
raised
content="This is a simple card with plain text, but cards can also contain their own header, footer, list view, image, or any other element."
></f7-card>
<f7-card
raised
title="Card header"
content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
footer="Card footer"
></f7-card>
<f7-card
raised
content="Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet. Mauris aliquet magna justo. "
></f7-card>
<f7-block-title>Styled Cards</f7-block-title>
<f7-card outline-md class="demo-card-header-pic">
<f7-card-header
valign="bottom"
style="background-image: url(https://cdn.framework7.io/placeholder/nature-1000x600-3.jpg)"
>Journey To Mountains</f7-card-header
>
<f7-card-content>
<p class="date">Posted on January 21, 2015</p>
<p>
Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies efficitur vitae non
felis. Phasellus quis nibh hendrerit...
</p>
</f7-card-content>
<f7-card-footer>
<f7-link>Like</f7-link>
<f7-link>Read more</f7-link>
</f7-card-footer>
</f7-card>
<f7-card class="demo-card-header-pic">
<f7-card-header
valign="bottom"
style="background-image: url(https://cdn.framework7.io/placeholder/people-1000x600-6.jpg)"
>Journey To Mountains</f7-card-header
>
<f7-card-content>
<p class="date">Posted on January 21, 2015</p>
<p>
Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies efficitur vitae non
felis. Phasellus quis nibh hendrerit...
</p>
</f7-card-content>
<f7-card-footer>
<f7-link>Like</f7-link>
<f7-link>Read more</f7-link>
</f7-card-footer>
</f7-card>
<f7-block-title>Cards With List View</f7-block-title>
<f7-card>
<f7-card-content :padding="false">
<f7-list>
<f7-list-item link="#">Link 1</f7-list-item>
<f7-list-item link="#">Link 2</f7-list-item>
<f7-list-item link="#">Link 3</f7-list-item>
<f7-list-item link="#">Link 4</f7-list-item>
<f7-list-item link="#">Link 5</f7-list-item>
</f7-list>
</f7-card-content>
</f7-card>
<f7-card title="New Releases:">
<f7-card-content :padding="false">
<f7-list medial-list>
<f7-list-item title="Yellow Submarine" subtitle="Beatles">
<template #media>
<img src="https://cdn.framework7.io/placeholder/fashion-88x88-4.jpg" width="44" />
</template>
</f7-list-item>
<f7-list-item title="Don't Stop Me Now" subtitle="Queen">
<template #media>
<img src="https://cdn.framework7.io/placeholder/fashion-88x88-5.jpg" width="44" />
</template>
</f7-list-item>
<f7-list-item title="Billie Jean" subtitle="Michael Jackson">
<template #media>
<img src="https://cdn.framework7.io/placeholder/fashion-88x88-6.jpg" width="44" />
</template>
</f7-list-item>
</f7-list>
</f7-card-content>
<f7-card-footer>
<span>January 20, 2015</span>
<span>5 comments</span>
</f7-card-footer>
</f7-card>
</f7-page>
</template>
<script>
import {
f7Navbar,
f7Page,
f7Block,
f7BlockTitle,
f7Card,
f7CardHeader,
f7CardContent,
f7CardFooter,
f7List,
f7ListItem,
f7Link,
} from 'framework7-vue';
export default {
components: {
f7Navbar,
f7Page,
f7Block,
f7BlockTitle,
f7Card,
f7CardHeader,
f7CardContent,
f7CardFooter,
f7List,
f7ListItem,
f7Link,
},
};
</script>