vue学习笔记 修改el-card样式

<template>
  <div style="margin: 50px">
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span>卡片名称</span>
          <el-button class="button" type="text">操作按钮</el-button>
        </div>
      </template>
      <div style="height: 200px"></div>
    </el-card>
  </div>
</template>
<script>
export default {
  name: "DevSort",
};
</script>
<style lang="scss" scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 0px;
  margin-top: 10px;
}

.box-card {
  width: 480px;
}


</style>


显示样式
在这里插入图片描述

1、修改header样式

.el-card ::v-deep .el-card__header {
  padding: 2px 10px;
  background-color: palegoldenrod;
}

在这里插入图片描述
2、修改body样式

.el-card ::v-deep .el-card__body {
  padding: 0px;
  background-color: powderblue;
}

在这里插入图片描述

  • 17
    点赞
  • 48
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
Vue3 中循环添加 `el-card` 可以使用 `v-for` 指令和组件的方式来实现。首先需要将 `el-card` 封装成一个组件,然后在父组件中使用 `v-for` 循环渲染这个组件。 下面是一个示例代码: ```html <template> <div> <my-card v-for="(item, index) in cardList" :key="index" :title="item.title" :content="item.content"></my-card> </div> </template> <script> import MyCard from './MyCard.vue'; export default { components: { MyCard }, data() { return { cardList: [ { title: 'Card 1', content: 'This is the content of card 1' }, { title: 'Card 2', content: 'This is the content of card 2' }, { title: 'Card 3', content: 'This is the content of card 3' } ] }; } }; </script> ``` 在这个示例中,我们将 `el-card` 封装成了一个名为 `MyCard` 的组件,在父组件中使用 `v-for` 循环渲染这个组件,并将 `cardList` 数组中的数据作为组件的属性传递给 `MyCard` 组件。 `MyCard` 组件的代码如下: ```html <template> <el-card :body-style="{ padding: '20px' }"> <div slot="header" class="clearfix"> <span>{{ title }}</span> </div> <div>{{ content }}</div> </el-card> </template> <script> export default { props: { title: { type: String, required: true }, content: { type: String, required: true } } }; </script> ``` 在 `MyCard` 组件中,我们接收了父组件传递过来的 `title` 和 `content` 属性,并将它们绑定到 `el-card` 组件上。 这样,在父组件中使用 `v-for` 循环渲染 `MyCard` 组件时,每个 `MyCard` 组件都会显示一个 `el-card`,并且根据传递进来的属性渲染出不同的内容。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值