国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

Vant2 Cell 單元格

2025-08-27 09:46 更新

介紹

單元格為列表中的單個展示項。

引入

import Vue from 'vue';
import { Cell, CellGroup } from 'vant';

Vue.use(Cell);
Vue.use(CellGroup);

代碼演示

基礎用法

Cell 可以單獨使用,也可以與 CellGroup 搭配使用,CellGroup 可以為 Cell 提供上下外邊框。

<van-cell-group>
  <van-cell title="單元格" value="內容" />
  <van-cell title="單元格" value="內容" label="描述信息" />
</van-cell-group>

卡片風格

通過 CellGroup 的 inset 屬性,可以將單元格轉換為圓角卡片風格(從 2.12.25 版本開始支持)。

<van-cell-group inset>
  <van-cell title="單元格" value="內容" />
  <van-cell title="單元格" value="內容" label="描述信息" />
</van-cell-group>

單元格大小

通過 size 屬性可以控制單元格的大小。

<van-cell title="單元格" value="內容" size="large" />
<van-cell title="單元格" value="內容" size="large" label="描述信息" />

展示圖標

通過 icon 屬性在標題左側展示圖標。

<van-cell title="單元格" icon="location-o" />

只設置 value

只設置 value 時,內容會靠左對齊。

<van-cell value="內容" />

展示箭頭

設置 is-link 屬性后會在單元格右側顯示箭頭,并且可以通過 arrow-direction 屬性控制箭頭方向。

<van-cell title="單元格" is-link />
<van-cell title="單元格" is-link value="內容" />
<van-cell title="單元格" is-link arrow-direction="down" value="內容" />

頁面導航

可以通過 url 屬性進行 URL 跳轉,或通過 to 屬性進行路由跳轉。

<van-cell title="URL 跳轉" is-link url="/vant/mobile.html" />
<van-cell title="路由跳轉" is-link to="index" />

分組標題

通過 CellGroup 的 title 屬性可以指定分組標題。

<van-cell-group title="分組1">
  <van-cell title="單元格" value="內容" />
</van-cell-group>
<van-cell-group title="分組2">
  <van-cell title="單元格" value="內容" />
</van-cell-group>

使用插槽

如以上用法不能滿足你的需求,可以使用插槽來自定義內容。

<van-cell value="內容" is-link>
  <!-- 使用 title 插槽來自定義標題 -->
  <template #title>
    <span class="custom-title">單元格</span>
    <van-tag type="danger">標簽</van-tag>
  </template>
</van-cell>

<van-cell title="單元格" icon="shop-o">
  <!-- 使用 right-icon 插槽來自定義右側圖標 -->
  <template #right-icon>
    <van-icon name="search" class="search-icon" />
  </template>
</van-cell>

<style>
  .custom-title {
    margin-right: 4px;
    vertical-align: middle;
  }

  .search-icon {
    font-size: 16px;
    line-height: inherit;
  }
</style>

垂直居中

通過 center 屬性可以讓 Cell 的左右內容都垂直居中。

<van-cell center title="單元格" value="內容" label="描述信息" />

API

CellGroup Props

參數(shù) 說明 類型 默認值
title 分組標題 string -
border 是否顯示外邊框 boolean true

Cell Props

參數(shù) 說明 類型 默認值
title 左側標題 number | string -
value 右側內容 number | string -
label 標題下方的描述信息 string -
size 單元格大小,可選值為 large string -
icon 左側圖標名稱或圖片鏈接 string -
icon-prefix v2.5.3 圖標類名前綴,同 Icon 組件的 class-prefix 屬性 string van-icon
url 點擊后跳轉的鏈接地址 string -
to 點擊后跳轉的目標路由對象,同 vue-router 的 to 屬性 string | object -
border 是否顯示內邊框 boolean true
replace 是否在跳轉時替換當前頁面歷史 boolean false
clickable 是否開啟點擊反饋 boolean null
is-link 是否展示右側箭頭并開啟點擊反饋 boolean false
required 是否顯示表單必填星號 boolean false
center 是否使內容垂直居中 boolean false
arrow-direction 箭頭方向,可選值為 left up down string right
title-style 左側標題額外樣式 any -
title-class 左側標題額外類名 any -
value-class 右側內容額外類名 any -
label-class 描述信息額外類名 any -

Cell Events

事件名 說明 回調參數(shù)
click 點擊單元格時觸發(fā) event: Event

CellGroup Slots

名稱 說明
default 默認插槽
title 自定義分組標題

Cell Slots

名稱 說明
default 自定義右側 value 的內容
title 自定義左側 title 的內容
label 自定義標題下方 label 的內容
icon 自定義左側圖標
right-icon 自定義右側按鈕,默認為arrow
extra 自定義單元格最右側的額外內容

樣式變量

組件提供了下列 Less 變量,可用于自定義樣式,使用方法請參考主題定制。

名稱 默認值 描述
@cell-font-size @font-size-md -
@cell-line-height 24px -
@cell-vertical-padding 10px -
@cell-horizontal-padding @padding-md -
@cell-text-color @text-color -
@cell-background-color @white -
@cell-border-color @border-color -
@cell-active-color @active-color -
@cell-required-color @red -
@cell-label-color @gray-6 -
@cell-label-font-size @font-size-sm -
@cell-label-line-height @line-height-sm -
@cell-label-margin-top @padding-base -
@cell-value-color @gray-6 -
@cell-icon-size 16px -
@cell-right-icon-color @gray-6 -
@cell-large-vertical-padding @padding-sm -
@cell-large-title-font-size @font-size-lg -
@cell-large-label-font-size @font-size-md -
@cell-group-background-color @white -
@cell-group-title-color @gray-6 -
@cell-group-title-padding @padding-md @padding-md @padding-xs -
@cell-group-title-font-size @font-size-md -
@cell-group-title-line-height 16px -


以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號