前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Vue:使用slot-scope插槽

Vue:使用slot-scope插槽

作者头像
沈宥
发布2024-07-11 10:20:58
750
发布2024-07-11 10:20:58
举报
文章被收录于专栏:从头开始学习测试开发

slot-scope介绍

  • slot-scope就是作用域插槽。官方叫它作用域插槽,实际上,对比具名插槽,我们可以叫它带数据的插槽。具名插槽在组件的template里面写,作用域插槽要求,在slot上面绑定数据。

实例

如何使用slot-scope

代码语言:javascript
复制
<el-table-column prop="report_name" label="diff结果">
          <template slot-scope="scope">
            <a :href="'http://host.com/report/'+scope.row.report_name" target="_blank" class="buttonText"
               onclick='window.open("http://host.com/report/"+scope.row.report_name)'>{{
              "host.com/report/"+scope.row.report_name }}</a>
          </template>
</el-table-column>

上述实现的功能

template(模版) 在这里属于一个固定用法:`<template slot-scope="scope">`,我们只是能通过scope.row获得当前的行数据

1、href:拼接scope.row.report_name,赋值跳转链接 2、onclick:拼接scope.row.report_name,生成新打开标签的URL链接 3、{{ }}:拼接scope.row.report_name,当前行显示的链接文本

展示效果

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-05-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从头开始学习测试开发 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • slot-scope介绍
  • 实例
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档