Element-React Card 卡片

将信息聚合在卡片容器中展示。

基础用法

包含标题,内容和操作。

Card 组件包括headerbody部分,header部分需要有显式具名 slot 分发,同时也是可选的。
Element-React Card 卡片

render() {
  return (
    <Card
      className="box-card"
      header={
        <div className="clearfix">
          <span style={{ "lineHeight": "36px" }}>卡片名称</span>
          <span style={{ "float": "right" }}>
            <Button type="primary">操作按钮</Button>
          </span>
        </div>
      }
    >
      <div className="text item">列表内容 1</div>
      <div className="text item">列表内容 2</div>
      <div className="text item">列表内容 3</div>
      <div className="text item">列表内容 4</div>
    </Card>
  )
}

简单卡片

卡片可以只有内容区域。

Element-React Card 卡片

render() {
  return (
    <Card className="box-card">
      <div className="text item">列表内容 0</div>
      <div className="text item">列表内容 1</div>
      <div className="text item">列表内容 2</div>
      <div className="text item">列表内容 3</div>
    </Card>
  )
}

带图片

可配置定义更丰富的内容展示。

配置body-style属性来自定义body部分的style,我们还使用了布局组件。

Element-React Card 卡片

render() {
  return (
    <Layout.Row>
      <Layout.Col span={ 8 } offset={ 0 }>
        <Card bodyStyle={{ padding: 0 }}>
          <img src={this.props.imgSrc} className="image" />
          <div style={{ padding: 14 }}>
            <span>好吃的汉堡</span>
            <div className="bottom clearfix">
              <time className="time">2016-10-21 16:19</time>
              <Button type="text" className="button">操作按钮</Button>
            </div>
          </div>
        </Card>
      </Layout.Col>
      <Layout.Col span={ 8 } offset={ 2 }>
        <Card bodyStyle={{ padding: 0 }}>
          <img src={this.props.imgSrc} className="image" />
          <div style={{ padding: 14 }}>
            <span>好吃的汉堡</span>
            <div className="bottom clearfix">
              <time className="time">2016-10-21 16:19</time>
              <Button type="text" className="button">操作按钮</Button>
            </div>
          </div>
        </Card>
      </Layout.Col>
    </Layout.Row>
  )
}

Attributes

参数说明类型可选值默认值
header设置 header,也可以通过 slot#header 传入 DOMstring
bodyStyle设置 body 的样式object{ padding: 20px }

作者:唐伯虎点蚊香,如若转载,请注明出处:https://www.web176.com/elementreact/19970.html

(0)
打赏 支付宝 支付宝 微信 微信
唐伯虎点蚊香的头像唐伯虎点蚊香
上一篇 2023年5月11日
下一篇 2023年5月11日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注