组件间使用插槽

 <template slot-scope="scope">
    <div>{{ scope.row.zukeName }}/{{ scope.row.zukePhone }}</div>
    <div>{{ scope.row.rentStartTime}}-{{scope.row.rentEndTime}}</div>
  </template>
</el-table-column>
<el-table-column prop="money" min-width="100" label="押金/租金/付款方式">
  <template slot-scope="scope" style="margin-left: -1px">
    <div>{{scope.row.deposit}}/{{scope.row.deposit}}
      <el-button type="text" size="small">
        <el-dropdown @command="queryRentInformationFn">
          <span class="el-dropdown-link">
             <i class="el-icon-view"></i>
          </span>

1.列表项  在table表格里可以插入模板  模板里可以插入插槽 slot-cope可以放多个 作用域可以有多个属性 直接使用{{scope.row.属性名}}就可以显示多个

2 命名属性的名字的时候要以后台的接口文档的参数为准 要不然后期还要修改 加大工作量

3element字体 小图标在使用的时候为了能显示要放在div 或者span里用 才能显示




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当我们封装一个 Vue 组件时,可以使用插槽(slot)来让组件使用者可以在组件内部入内容。使用插槽可以让我们的组件更加灵活和可复用。 在组件内部,我们可以使用 `slot` 标签来声明一个插槽。例如: ```html <template> <div class="my-component"> <h2>这是组件的标题</h2> <slot></slot> </div> </template> ``` 上面的代码,我们在组件的模板使用了 `slot` 标签,这个标签表示这个组件需要一个插槽使用这个组件的时候,我们可以在组件标签内部入任意的内容,这些内容会被入到 `slot` 标签的位置上。 例如,我们可以这样使用这个组件: ```html <template> <div> <MyComponent> <p>这里是入到组件的内容</p> </MyComponent> </div> </template> ``` 这样,`<p>这里是入到组件的内容</p>` 就会被入到组件的模板的 `slot` 标签的位置上。 如果我们需要多个插槽,可以给 `slot` 标签添加一个 `name` 属性来区分不同的插槽。例如: ```html <template> <div class="my-component"> <h2>这是组件的标题</h2> <slot name="header"></slot> <div class="content"> <slot></slot> </div> <slot name="footer"></slot> </div> </template> ``` 上面的代码,我们声明了三个插槽,分别是名为 `header`、`default` 和 `footer` 的插槽使用这个组件时,我们可以这样入内容: ```html <template> <div> <MyComponent> <template v-slot:header> <h3>这是头部插槽的内容</h3> </template> <p>这里是默认插槽的内容</p> <template v-slot:footer> <p>这是底部插槽的内容</p> </template> </MyComponent> </div> </template> ``` 上面的代码,我们使用了带 `v-slot` 的 `<template>` 标签来指定要入哪个插槽,例如 `v-slot:header` 表示要入到名为 `header` 的插槽。在 `<template>` 标签内部,我们可以入任意的内容,这些内容会被入到对应的插槽位置上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值