Skip to content

Cell 单元格 ​

介绍 ​

列表项,可组成列表。

基础用法 ​

html
<template>
  <mot-cell title="我是标题" desc="描述文字"></mot-cell>
  <mot-cell title="我是标题" sub-title="副标题描述" desc="描述文字"></mot-cell>
  <mot-cell title="点击测试" @click="testClick"></mot-cell>
  <mot-cell title="圆角设置 0" round-radius="0"></mot-cell>
</template>
<script>
  import { ref } from 'vue';
  export default {
    setup() {
      const switchChecked = ref(true);
      const testClick = (event) => {
        console.log('Click Test');
      };
      return { testClick, switchChecked };
    }
  };
</script>

尺寸设置 large ​

html
<template>
  <mot-cell size="large" title="我是标题" desc="描述文字"></mot-cell>
  <mot-cell size="large" title="我是标题" sub-title="副标题描述" desc="描述文字"></mot-cell>
</template>

直接使用插槽(slot) ​

html
<template>
  <mot-cell>
    <div>自定义内容</div>
  </mot-cell>
</template>

直接使用插槽(slot title) ​

html
<template>
  <mot-cell desc="描述文字">
      <template v-slot:title>
        <span>Title <b style="color: red">1</b></span>
      </template>
  </mot-cell>
</template>

链接 | 分组用法 ​

html
<template>
  <mot-cell-group title="链接 | 分组用法" desc="使用 mot-cell-group 支持 title desc slots">
    <mot-cell title="链接" is-link></mot-cell>
    <mot-cell title="URL 跳转" desc="https://m.jd.com" is-link url="https://m.jd.com"></mot-cell>
    <mot-cell title="路由跳转 ’/‘ " to="/"></mot-cell>
  </mot-cell-group>
</template>

自定义右侧箭头区域 ​

html
<template>
  <mot-cell-group title="自定义右侧箭头区域">
    <mot-cell title="Switch">
      <template v-slot:link>
        <mot-switch v-model="switchChecked" />
      </template>
    </mot-cell>
  </mot-cell-group>
</template>
<script lang="ts">
  import { ref } from 'vue';
  export default {
    setup() {
      const testClick = (event: Event) => {
        console.log('点击事件');
      };
      const switchChecked = ref(true);
      return { testClick, switchChecked };
    }
  };
</script>

自定义左侧 Icon 区域 ​

html
<template>
  <mot-cell-group title="自定义左侧 Icon 区域">
    <mot-cell title="图片">
      <template v-slot:icon>
        <img
          class="mot-icon"
          src="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
        />
      </template>
    </mot-cell>
  </mot-cell-group>
</template>

展示图标 ​

html
<template>
  <mot-cell title="姓名" icon="my" desc="张三"></mot-cell>
</template>

只展示 desc ,可通过 desc-text-align 调整内容位置 ​

html
<template>
  <mot-cell desc-text-align="left" desc="张三"></mot-cell>
</template>

垂直居中 ​

通过 center 属性可以让 Cell 的左右内容都垂直居中。

html
<template>
  <mot-cell center title="我是标题" sub-title="副标题描述" desc="描述文字"></mot-cell>
</template>

直接使用插槽(slot desc) ​

vue
<template>
  <mot-cell title="我是标题">
    <template #desc>
      <span>描述文字 <b style="color: red">2</b></span>
    </template>
  </mot-cell>
</template>

API ​

CellGroup Props ​

参数说明类型默认值
title分组标题string-
desc分组描述string-

Cell Props ​

参数说明类型默认值
title标题名称string-
sub-title左侧副标题string-
desc右侧描述string-
desc-text-align右侧描述文本对齐方式 text-alignstringright
is-link是否展示右侧箭头并开启点击反馈booleanfalse
to 1.7.8跳转地址(uni.navigateTo的url参数)string-
round-radius圆角半径number6px
center是否使内容垂直居中booleanfalse
size单元格大小,可选值为 largestring-

Cell Events ​

事件名说明回调参数
click点击事件event:Event

Cell Slots ​

名称说明
icon自定义左侧 icon 区域
default自定义内容
link自定义右侧 link 区域
title自定义 title 标题区域
desc 1.1.6自定义 desc 描述区域

CellGroup Slots ​

名称说明
title自定义 title 标题区域
desc自定义 desc 描述区域

主题定制 ​

样式变量 ​

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件。

名称默认值
--mot-cell-colorvar(--mot-title-color2)
--mot-cell-title-fontvar(--mot-font-size-2)
--mot-cell-title-desc-fontvar(--mot-font-size-1)
--mot-cell-desc-fontvar(--mot-font-size-2)
--mot-cell-desc-colorvar(--mot-disable-color)
--mot-cell-border-radius6px
--mot-cell-padding13px 16px
--mot-cell-line-height20px
--mot-cell-after-right16px
--mot-cell-after-border-bottom1px solid #f5f6f7
--mot-cell-default-icon-margin0 4px 0 0px
--mot-cell-large-title-fontvar(--mot-font-size-large)
--mot-cell-large-title-desc-fontvar(--mot-font-size-base)
--mot-cell-large-padding15px 16px
--mot-cell-backgroundvar(--mot-white)
--mot-cell-box-shadow0px 1px 7px 0px rgba(237, 238, 241, 1)
--mot-cell-group-title-padding0 10px
--mot-cell-group-title-color#909ca4
--mot-cell-group-title-font-sizevar(--mot-font-size-2)
--mot-cell-group-title-line-height20px
--mot-cell-group-desc-padding0 10px
--mot-cell-group-desc-color#909ca4
--mot-cell-group-desc-font-sizevar(--mot-font-size-1)
--mot-cell-group-desc-line-height16px
--mot-cell-group-background-colorvar(--mot-white)

MIT Licensed