W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
import Vue from 'vue';
import { Cell, CellGroup } from 'vant';
Vue.use(Cell);
Vue.use(CellGroup);
Cell可以單獨(dú)使用,也可以與CellGroup搭配使用。CellGroup可以為Cell提供上下外邊框
<van-cell-group>
<van-cell title="單元格" value="內(nèi)容" />
<van-cell title="單元格" value="內(nèi)容" label="描述信息" />
</van-cell-group>
通過size屬性可以控制單元格的大小
<van-cell title="單元格" value="內(nèi)容" size="large" />
<van-cell title="單元格" value="內(nèi)容" size="large" label="描述信息" />
通過icon屬性在標(biāo)題左側(cè)展示圖標(biāo)
<van-cell title="單元格" icon="location-o" />
只設(shè)置value時(shí),內(nèi)容會(huì)靠左對(duì)齊
<van-cell value="內(nèi)容" />
設(shè)置is-link屬性后會(huì)在單元格右側(cè)顯示箭頭,并且可以通過arrow-direction屬性控制箭頭方向
<van-cell title="單元格" is-link />
<van-cell title="單元格" is-link value="內(nèi)容" />
<van-cell title="單元格" is-link arrow-direction="down" value="內(nèi)容" />
可以通過url屬性進(jìn)行 URL 跳轉(zhuǎn),或通過to屬性進(jìn)行路由跳轉(zhuǎn)
<van-cell title="URL 跳轉(zhuǎn)" is-link url="/vant/mobile.html" />
<van-cell title="路由跳轉(zhuǎn)" is-link to="index" />
通過CellGroup的title屬性可以指定分組標(biāo)題
<van-cell-group title="分組1">
<van-cell title="單元格" value="內(nèi)容" />
</van-cell-group>
<van-cell-group title="分組2">
<van-cell title="單元格" value="內(nèi)容" />
</van-cell-group>
如以上用法不能滿足你的需求,可以使用插槽來自定義內(nèi)容
<van-cell value="內(nèi)容" is-link>
<!-- 使用 title 插槽來自定義標(biāo)題 -->
<template slot="title">
<span class="custom-title">單元格</span>
<van-tag type="danger">標(biāo)簽</van-tag>
</template>
</van-cell>
<van-cell title="單元格" icon="shop-o">
<!-- 使用 right-icon 插槽來自定義右側(cè)圖標(biāo) -->
<van-icon
slot="right-icon"
name="search"
style="line-height: inherit;"
/>
</van-cell>
通過center屬性可以讓Cell的左右內(nèi)容都垂直居中
<van-cell center title="單元格" value="內(nèi)容" label="描述信息" />
參數(shù) | 說明 | 類型 | 默認(rèn)值 |
---|---|---|---|
title | 分組標(biāo)題 | string | - |
border | 是否顯示外邊框 | boolean | true |
參數(shù) | 說明 | 類型 | 默認(rèn)值 |
---|---|---|---|
icon | 左側(cè) 圖標(biāo)名稱 或圖片鏈接 | string | - |
title | 左側(cè)標(biāo)題 | number | string | - |
value | 右側(cè)內(nèi)容 | number | string | - |
label | 標(biāo)題下方的描述信息 | string | - |
size | 單元格大小,可選值為 large | string | - |
url | 點(diǎn)擊后跳轉(zhuǎn)的鏈接地址 | string | - |
to | 點(diǎn)擊后跳轉(zhuǎn)的目標(biāo)路由對(duì)象,同 vue-router 的 to 屬性 | string | object | - |
border | 是否顯示內(nèi)邊框 | boolean | true |
replace | 是否在跳轉(zhuǎn)時(shí)替換當(dāng)前頁面歷史 | boolean | false |
clickable | 是否開啟點(diǎn)擊反饋 | boolean | false |
is-link | 是否展示右側(cè)箭頭并開啟點(diǎn)擊反饋 | boolean | false |
required | 是否顯示表單必填星號(hào) | boolean | false |
center | 是否使內(nèi)容垂直居中 | boolean | false |
arrow-direction | 箭頭方向,可選值為 left up down | string | right |
title-style | 左側(cè)標(biāo)題額外樣式 | any | - |
title-class | 左側(cè)標(biāo)題額外類名 | any | - |
value-class | 右側(cè)內(nèi)容額外類名 | any | - |
label-class | 描述信息額外類名 | any | - |
事件名 | 說明 | 回調(diào)參數(shù) |
---|---|---|
click | 點(diǎn)擊單元格時(shí)觸發(fā) | event: Event |
名稱 | 說明 |
---|---|
default | 默認(rèn)插槽 |
title | 自定義分組標(biāo)題 |
名稱 | 說明 |
---|---|
default | 自定義右側(cè)內(nèi)容 |
title | 自定義左側(cè)標(biāo)題 |
label | 自定義標(biāo)題下方描述 |
icon | 自定義左側(cè)圖標(biāo) |
right-icon | 自定義右側(cè)按鈕,默認(rèn)為arrow |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: