Chip Vue组件
芯片(标签)Vue组件在小型块中表示复杂实体,例如联系人。它们可以包含照片、简短的标题字符串和简要信息
芯片组件
包含以下组件:
f7-chip
芯片属性
属性 | 类型 | 默认 | 描述 |
---|---|---|---|
<f7-chip>属性 | |||
text | 字符串 | 芯片标签文本 | |
media | 字符串 | 芯片媒体文本内容 | |
media-bg-color | 字符串 | 芯片媒体元素背景颜色。其中之一默认颜色之一 | |
media-text-color | 字符串 | 芯片媒体元素文本颜色。其中之一默认颜色之一 | |
deleteable | 布尔值 | false | 定义芯片是否有附加的“删除”按钮 |
outline | 布尔值 | false | 使芯片轮廓 |
提示 | 字符串 | 提示鼠标悬停/点击时显示的文本 | |
tooltip-trigger | 字符串 | 悬停 | 定义如何触发(打开)提示。可以是hover , click 或manual |
<f7-chip>与图标相关的属性 | |||
icon-size | 字符串 数字 | 图标大小(像素) | |
icon-color | 字符串 | 图标颜色。可以是默认颜色之一 | |
icon | 字符串 | 自定义图标类 | |
icon-f7 | 字符串 | F7 图标字体图标的名称 | |
icon-material | 字符串 | Material 图标字体图标的名称 | |
icon-ios | 字符串 | 在使用 iOS 主题时使用的图标。由图标系列和图标名称组成,例如f7:house | |
icon-md | 字符串 | 在使用 MD 主题时使用的图标。由图标系列和图标名称组成,例如material:home |
芯片事件
事件 | 描述 |
---|---|
<f7-chip>事件 | |
click | 点击芯片时将触发事件 |
删除 | 点击芯片删除按钮时将触发事件 |
芯片插槽
Chip Vue组件有额外的插槽用于自定义元素:
text
- 元素将替换芯片文本标签插入default
- 与text
)media
- 元素将插入到芯片的媒体元素中
示例
chips.vue
<template>
<f7-page>
<f7-navbar title="Chips"></f7-navbar>
<f7-block-title>Chips With Text</f7-block-title>
<f7-block strong-ios outline-ios>
<f7-chip text="Example Chip"></f7-chip>
<f7-chip text="Another Chip"></f7-chip>
<f7-chip text="One More Chip"></f7-chip>
<f7-chip text="Fourth Chip"></f7-chip>
<f7-chip text="Last One"></f7-chip>
</f7-block>
<f7-block-title>Outline Chips</f7-block-title>
<f7-block strong-ios outline-ios>
<f7-chip outline text="Example Chip"></f7-chip>
<f7-chip outline text="Another Chip"></f7-chip>
<f7-chip outline text="One More Chip"></f7-chip>
<f7-chip outline text="Fourth Chip"></f7-chip>
<f7-chip outline text="Last One"></f7-chip>
</f7-block>
<f7-block-title>Icon Chips</f7-block-title>
<f7-block strong-ios outline-ios>
<f7-chip text="Add Contact" media-bg-color="blue">
<template #media>
<f7-icon ios="f7:plus_circle" md="material:add_circle" />
</template>
</f7-chip>
<f7-chip text="London" media-bg-color="green">
<template #media>
<f7-icon ios="f7:compass" md="material:location_on" />
</template>
</f7-chip>
<f7-chip text="John Doe" media-bg-color="red">
<template #media>
<f7-icon ios="f7:person" md="material:person" />
</template>
</f7-chip>
</f7-block>
<f7-block-title>Contact Chips</f7-block-title>
<f7-block strong-ios outline-ios>
<f7-chip text="Jane Doe">
<template #media>
<img src="https://cdn.framework7.io/placeholder/people-100x100-9.jpg" />
</template>
</f7-chip>
<f7-chip text="John Doe">
<template #media>
<img src="https://cdn.framework7.io/placeholder/people-100x100-3.jpg" />
</template>
</f7-chip>
<f7-chip text="Adam Smith">
<template #media>
<img src="https://cdn.framework7.io/placeholder/people-100x100-7.jpg" />
</template>
</f7-chip>
<f7-chip text="Jennifer" media-bg-color="pink" media="J"></f7-chip>
<f7-chip text="Chris" media-bg-color="yellow" media-text-color="black" media="C"></f7-chip>
<f7-chip text="Kate" media-bg-color="red" media="K"></f7-chip>
</f7-block>
<f7-block-title>Deletable Chips / Tags</f7-block-title>
<f7-block strong-ios outline-ios>
<f7-chip text="Example Chip" deleteable @delete="deleteChip"></f7-chip>
<f7-chip
text="Chris"
media="C"
media-bg-color="orange"
deleteable
@delete="deleteChip"
></f7-chip>
<f7-chip text="Jane Doe" deleteable @delete="deleteChip">
<template #media>
<img src="https://cdn.framework7.io/placeholder/people-100x100-9.jpg" />
</template>
</f7-chip>
<f7-chip text="One More Chip" deleteable @delete="deleteChip"></f7-chip>
<f7-chip
text="Jennifer"
media-bg-color="pink"
media="J"
deleteable
@delete="deleteChip"
></f7-chip>
<f7-chip text="Adam Smith" deleteable @delete="deleteChip">
<template #media>
<img src="https://cdn.framework7.io/placeholder/people-100x100-7.jpg" />
</template>
</f7-chip>
</f7-block>
<f7-block-title>Color Chips</f7-block-title>
<f7-block strong-ios outline-ios>
<f7-chip text="Red Chip" color="red"></f7-chip>
<f7-chip text="Green Chip" color="green"></f7-chip>
<f7-chip text="Blue Chip" color="blue"></f7-chip>
<f7-chip text="Orange Chip" color="orange"></f7-chip>
<f7-chip text="Pink Chip" color="pink"></f7-chip>
<f7-chip outline text="Red Chip" color="red"></f7-chip>
<f7-chip outline text="Green Chip" color="green"></f7-chip>
<f7-chip outline text="Blue Chip" color="blue"></f7-chip>
<f7-chip outline text="Orange Chip" color="orange"></f7-chip>
<f7-chip outline text="Pink Chip" color="pink"></f7-chip>
</f7-block>
</f7-page>
</template>
<script>
import { f7Navbar, f7Page, f7BlockTitle, f7Chip, f7Block, f7Icon, f7 } from 'framework7-vue';
import $ from 'dom7';
export default {
components: {
f7Navbar,
f7Page,
f7BlockTitle,
f7Chip,
f7Block,
f7Icon,
},
methods: {
deleteChip(e) {
const target = e.target;
f7.dialog.confirm('Do you want to delete this tiny demo Chip?', () => {
$(target).parents('.chip').remove();
});
},
},
};
</script>