当前位置: 首页 > news >正文

【sgFileLink】自定义组件:基于el-link、el-icon标签构建文件超链接组件,支持垃圾桶删除、点击预览视频/音频/图片/PDF格式文件

sgFileLink源代码

<template><div :class="$options.name"><el-link @click.stop="clickFile(data)"><img :src="getSrc(data)" /><span>{{ getFileNameAndSize(data) }}</span></el-link><el-linkclass="remove-btn"type="danger"v-if="clearable_"icon="el-icon-delete":title="`移除${data.name}`":underline="false"@click.stop="remove(data)"/><el-imageref="image"style="display: none"src="":initial-index="initialIndex":preview-src-list="previewSrcList"/><sgVideoDialog :data="data_sgVideoDialog" v-model="show_sgVideoDialog" /><sgAudioDialog :data="data_sgAudioDialog" v-model="show_sgAudioDialog" /></div>
</template>
<script>
import sgVideoDialog from "@/vue/components/admin/sgVideoDialog";
import sgAudioDialog from "@/vue/components/admin/sgAudioDialog";
import $com from "@/js/com";
export default {name: "sgFileLink",components: { sgVideoDialog, sgAudioDialog },data() {return {data_sgVideoDialog: {},show_sgVideoDialog: false,data_sgAudioDialog: {},show_sgAudioDialog: false,previewSrcList: null,initialIndex: 0,clearable_: null,};},props: ["data", "clearable", "files"],computed: {},watch: {clearable: {handler(newValue, oldValue) {this.clearable_ = newValue === "" || newValue;},deep: true, //深度监听immediate: true, //立即执行},},created() {},mounted() {},destroyed() {},methods: {remove(data) {this.$emit(`remove`, data);},clickFile(d) {$com.clickFile(d, this, { files: this.files });},getSrc(d) {typeof d === `string` && (d = JSON.parse(d));let fileName = d.name;let suffix = fileName.split(".").slice(-1)[0];return $com.getFlieThumbSrc({ suffix });},getFileNameAndSize(d) {return $com.getFileNameAndSize(d);},},
};
</script>
<style lang="scss" scoped>
.sgFileLink {>>> .el-link {transition: 0.2s;line-height: normal;img {width: 16px;height: 16px;object-position: center;object-fit: contain;transform: translateY(2px);margin-right: 5px;}span {word-wrap: break-word;word-break: break-all;white-space: break-spaces;}}.remove-btn {transition: 0.382s;opacity: 0;pointer-events: none;transform: translateX(-100%);}&:hover {.remove-btn {opacity: 1;pointer-events: auto;transform: translateX(0%);}}
}
</style>

应用

<sgFileLink :data="{ ...scope.row, clearable: true }" @remove="remove(scope.row, scope.$index)" />

http://www.lryc.cn/news/503886.html

相关文章:

  • Kafka - 消息乱序问题的常见解决方案和实现
  • 【golang】匿名内部协程,值传递与参数传递
  • Jenkins与SonarQube持续集成搭建及坑位详解
  • .NET6 WebAPI从基础到进阶--朝夕教育
  • 购物车案例--分模块存储数据,发送请求数据渲染,底部总计数量和价格
  • PCIe学习笔记
  • The Rise and Potential of Large Language ModelBased Agents:A Survey---讨论
  • C语言:const的用法
  • Redis - 集合 Set 及代码实战
  • LabVIEW面向对象编程有什么特点?
  • 配置Nginx自签名SSL证书,支持HTTPS
  • 使用Spring Boot、VUE实现SSE长连接:跟踪文件上传和任务进度
  • 计算机网络技术基础:3.计算机网络的拓扑结构
  • go-zero(十二)消息队列
  • 会议通知:人工智能通识教育与实践发展暨和鲸科技AI通识课解决方案发布会
  • UDS自动化测试-Service 0x27(CAPL调用dll实现key计算)
  • 订单编号如何实现
  • Vue3 大事件管理系统
  • IOS通过WDA自动化中遇到的问题
  • 单独测试 pyautogui 的鼠标点击功能,确保它能够在当前环境中正常工作,鼠标自动点击的录制回放功能
  • 路由引入问题(双点双向路由回馈问题)
  • 设计模式之 适配器模式 C# 范例
  • LabVIEW实现GPS通信
  • [leetcode100] 543. 二叉树的直径
  • 嵌入式学习(18)-stm32F407串口接收空闲中断+DMA
  • b站视频爬虫-词云分析
  • 如何防止订单二次重复支付?
  • LeetCode 24反转链表
  • 用python的flask写的一个MQTT中转功能,http的方式发送数据和接收数据
  • img引入svg如何修改颜色