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

网站的流程泰安电视台直播在线观看

网站的流程,泰安电视台直播在线观看,免费微信网站开发,做网站游戏都需要什么作者:fyupeng 技术专栏:☞ https://github.com/fyupeng 项目地址:☞ https://github.com/fyupeng/distributed-blog-system-api 留给读者 本文 一、介绍 对于PDF预览,有很多开发者都遇到过头疼的难题,今天给大家介绍…

作者:fyupeng
技术专栏:☞ https://github.com/fyupeng
项目地址:☞ https://github.com/fyupeng/distributed-blog-system-api


留给读者

本文

一、介绍

对于PDF预览,有很多开发者都遇到过头疼的难题,今天给大家介绍一个比较成熟的浏览器直接提供的预览嵌入Vue组件。

二、代码

  • 快速使用:

html渲染:

    <el-dialog:lock-scroll="false"custom-class="imgPreview_dia":show-close="true"top="5vh"width="90vw"v-model="dialogVisible"><filePreview :fileUrl="fileUrl" width="90vw" height="90vh"></filePreview></el-dialog>

css样式:

.imgPreview_dia {border-radius: 0 !important;margin: 0;left: 5vw;
}

js 处理:

const dialogVisible = ref(false);const fileUrl = ref("");const handleYulan = (index: number, row: object) => {fileUrl.value =// showDocFile() +"http://localhost:8086/machine/commonFile/notice/showDocFile" +"?fileId=" +row.fileId +"&pripid=" +props.initData?.pripid +"&time=" +new Date().getTime();// fileUrl.value =//   showDocFile() +//   "?docId=2516&gid=4055fb556a9c440590464017f28aae0e&time=1691460960121";dialogVisible.value = true;
};
  • 模板:

后端处理:

 public Boolean showNoticeDocFile(String fileId, HttpServletResponse response) {FileInputStream input = null;OutputStream output = null;try {File file = getNoticeDocRowFile(fileId);if (file == null || !file.exists()) {return false;}input = new FileInputStream(file);int i = input.available(); // 得到文件大小byte[] data = new byte[i];input.read(data); // 读数据response.setContentType("application/pdf"); // 设置返回的文件类型response.addHeader("Content-Length", String.valueOf(data.length));  //文件大小output = response.getOutputStream(); // 得到向客户端输出二进制数据的对象output.write(data); // 输出数据output.flush();file.delete();return true;} catch (Exception e) {logger.error("==showFile==文件信息回显失败!fileId:{}", fileId, e);return false;} finally {try {if (input != null)input.close();if (output != null)output.close();} catch (IOException e) {logger.error(e.getMessage(), e);}}}

前端处理:
filePreview.vue

<template><div class="wrap" v-loading="isLoading"><div class="pdf-container"><iframeid="doc-iframe":src="url":style="{ width: prop.width, height: prop.height, background: '#fff' }"class="parintDetailDoc"ref="iframeRef"></iframe></div></div>
</template><script lang="ts" setup>
import { ref, reactive, watch, defineProps, defineEmits, onMounted } from "vue";
import { ElMessage } from "element-plus";
const emits = defineEmits(["loaded"]);
const prop = defineProps({fileUrl: {type: String,default: "",},width: {type: String,default: "800px",},height: {type: String,default: "800px",},
});
const isLoading = ref(true);
const url = ref("");watch(() => prop.fileUrl,() => {url.value = prop.fileUrl;console.log("--------prop.fileUrl", prop.fileUrl);},{ immediate: true }
);
onMounted(() => {let iframeDom = document.getElementById("doc-iframe") || {};iframeDom.onload = function () {isLoading.value = false;emits("loaded");};
});
</script><style scoped>
.parintDetailDoc::-webkit-scrollbar {display: none;
}
.parintDetailDoc {border: none;max-width: 100%;
}
</style>

三、总结

简洁、高效、实用!

http://www.yayakq.cn/news/627278/

相关文章:

  • 群晖可以做网站吗聊城网站推广怎么做
  • 网站备案成功后怎么长春电商网站建设公司
  • 哈尔滨专业做网站国外的wordpress主题公园
  • 自己做的网页加在网站文章上为什么打不开一家做公司点评的网站
  • 女生做网站编辑好还是昆山科技网站建设
  • 网站优化建设上海阿里建站服务
  • 网站服务器排行榜青岛网站建设公司效果
  • 武都区建设局网站汕头网站建设技术支持
  • 个人网站设计怎么做百度公司的企业文化
  • 怎么在移动端网站下面做联系人中国互联网公司排名100强
  • 慕枫网站建设教人做家具的网站
  • 如何写网站建设方案如何给一个企业的网站做推广
  • 我的网站怎么转网页呢国外 网站设计
  • 建网站北京怎么下载网站的模板
  • 网站建设犀牛做软件代理去哪个网站
  • 设计制作一个 个人主页网站建网站盈利的几种方式
  • 免费网站域名注册个人国产比较好的精华
  • 网站建设的售后服务流程北京欢迎您
  • 自个网站上海网站开发培训价格
  • .net wap网站ui设计培训项目
  • 无锡网站建设seo合肥百度快照优化排名
  • 简洁的企业博客html5手机网站模板源码下载中兴的网站谁做的
  • 网站维护是怎么回事深圳市福田建设股份有限公司网站
  • 南京手机网站群晖wordpress站点地址
  • 兰州怎么提高网站的排名微信公众平台小程序登录
  • wordpress菜单小工具栏新媒体seo指的是什么
  • 漳平网站建设wordpress换主图之后图片不显示
  • 公众号建网站wordpress链接排序
  • gucci网站推荐做微商海报的网站
  • 高端网站建设 源码仙居做网站