vue+element:el-descriptions组件,数据绑定、内容样式和标签样式自定义

这篇博客展示了如何在Vue.js中使用el-descriptions组件结合自定义样式来展示从接口获取的数据。通过设置labelStyle和contentStyle属性,调整了各字段的宽度,实现了详细信息的清晰展示。同时,提供了JS调用代码,通过listAppointmentUnitDetail接口获取数据并赋值给this.appointUnitForm对象。
摘要由CSDN通过智能技术生成

1.绑定接口数据——默认样式展示(未自定义宽度):

2.绑定接口数据——自定义样式展示

3.使用的语法

labelStyle="width: 150px"
contentStyle="width: 250px"

4.Vue代码展示:

<el-descriptions class="margin-top" :column="3" style="width: 1250px" border>
      <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px">
        <template slot="label"><i class="el-icon-user"></i>预约单元名称</template>
        {{this.appointUnitForm.appointName}}
      </el-descriptions-item>
      <el-descriptions-item class="contentClassName">
        <template slot="label"><i class="el-icon-mobile-phone"></i>预约类别</template>
        {{this.appointUnitForm.appointType}}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="width: 200px" contentStyle="width: 200px">
        <template slot="label"><i class="el-icon-location-outline"></i>预约单元归属年份</template>
        {{this.appointUnitForm.appointYear}}
      </el-descriptions-item>
      <el-descriptions-item class="el-descriptions-item__cell">
        <template slot="label"><i class="el-icon-tickets"></i>创建时间</template>
        {{this.appointUnitForm.appointCtime}}
      </el-descriptions-item>
      <el-descriptions-item class="el-descriptions-item__cell">
        <template slot="label"><i class="el-icon-office-building"></i>启用状态</template>
        {{this.appointUnitForm.appointOpenFlag}}
      </el-descriptions-item>
      <el-descriptions-item class="el-descriptions-item__cell">
        <template slot="label"><i class="el-icon-star-off"></i>开放范围</template>
        {{this.appointUnitForm.appointOpenRange}}
      </el-descriptions-item>
      <el-descriptions-item class="el-descriptions-item__cell">
        <template slot="label"><i class="el-icon-goods"></i>操作人ID</template>
        {{this.appointUnitForm.appointOperator}}
      </el-descriptions-item>
      <el-descriptions-item class="el-descriptions-item__cell">
        <template slot="label"><i class="el-icon-picture-outline-round"></i>排序号</template>
        {{this.appointUnitForm.appointOrder}}
      </el-descriptions-item>
      <el-descriptions-item class="el-descriptions-item__cell">
        <template slot="label"><i class="el-icon-bell"></i>备注</template>
        {{this.appointUnitForm.appointMemo}}
      </el-descriptions-item>
    </el-descriptions>

5.JS调用代码展示——传递回来的接口数据——this.appointUnitForm的数据类型——对象

关键代码:this.appointUnitForm = response

/** 查询数据列表 */
      getList() {
        this.loading = true
        console.log("this.$route.params.appointId:", this.$route.params.appointId)

        listAppointmentUnitDetail(this.$route.params.appointId).then(response => {
          this.appointUnitForm = response
          console.log("response:", response)

          this.loading = false

        })
      },

6.JS请求代码展示

import request from "../../../utils/request";

// 后端接口:查询1条详情
export function listAppointmentUnitDetail(id) {
  return request({
    url: '/center/appointUnit/detail/' + id,
    method: 'get',
  })
}

  • 22
    点赞
  • 70
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值