neverland 16fe6b2e6d
[new feature] Cell support vue-router target route (#268)
* [bugfix] CouponList always show empty info

* [bugfix] add click feedback of buttons in components

* [Doc] add custom theme document

* [new feature] Notice bar support more props

* [bugfix] PullRefresh test cases

* [bugfix] unused NoticeBar style

* [bugfix] Swipe width calc error

* [Doc] english document of all action components

* [Doc] change document site path to /zanui/vant

* [Doc] fix

* [bugfix] uploader style error

* [bugfix] tabs document demo

* [new feature] Cell support vue-router target route

* [bugfix] add cell test cases

* update yarn.lock
2017-10-30 05:39:32 -05:00

2.9 KiB

Cell 单元格

使用指南

import { Cell, CellGroup } from 'vant';

Vue.component(Cell.name, Cell);
Vue.component(CellGroup.name, CellGroup);

代码演示

基础用法

van-cell-group组件看成一个容器即可

:::demo 基础用法

<van-cell-group>
  <van-cell title="单元格1" value="单元格1内容"></van-cell>
  <van-cell title="单元格2" value="单元格2内容" label="描述信息"></van-cell>
</van-cell-group>

:::

只设置value

只设置value时会向左对齐

:::demo 只设置value

<van-cell-group>
  <van-cell value="单元格内容"></van-cell>
</van-cell-group>

:::

展示图标

通过icon属性在标题左侧展示图标 :::demo 展示图标

<van-cell-group>
  <van-cell title="单元格" icon="location"></van-cell>
</van-cell-group>

:::

展示箭头

传入isLink属性则会在右侧显示箭头

:::demo 展示箭头

<van-cell-group>
  <van-cell title="单元格1" is-link></van-cell>
  <van-cell title="单元格2" is-link value="内容"></van-cell>
</van-cell-group>

:::

高级用法

如以上用法不能满足你的需求,可以使用对应的slot来自定义显示的内容

:::demo 高级用法

<van-cell-group>
  <van-cell value="进入店铺" icon="shop" is-link>
    <template slot="title">
      <span class="van-cell-text">起码运动馆</span>
      <van-tag type="danger">官方</van-tag>
    </template>
  </van-cell>
  <van-cell title="线下门店" icon="location" is-link></van-cell>
  <van-cell title="其他">
    <template slot="right-icon">
      <van-icon name="search" class="van-cell__right-icon"></van-icon>
    </template>
  </van-cell>
</van-cell-group>

:::

API

参数 说明 类型 默认值 可选值
icon 左侧图标 String - -
title 左侧标题 String - -
value 右侧内容 String - -
label 标题下方的描述信息 String - -
url 跳转链接 String - -
to 路由跳转对象,同 vue-router 的 to `String Object` -
replace 跳转时是否替换当前 history String false -
isLink 是否展示右侧箭头 Boolean false -
required 是否显示表单必填符号 Boolean false -

Slot

name 描述
- 自定义显示内容
icon 自定义icon
title 自定义title
right-icon 自定义右侧按钮,默认是arrow