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

苏州做商城网站免费搜索引擎推广方法有哪些

苏州做商城网站,免费搜索引擎推广方法有哪些,电子商务网站建设怎么做,宁波网今天一天对当前可用的pdf预览插件做了测试,主要需求是只能预览不能下载,但对于前端来说,没有绝对的禁止,这里只罗列实现方式。 目前采用vue3版本为:3.2.37 iframevue-officepdfjs-dist iframe 先说最简单的&#xf…

今天一天对当前可用的pdf预览插件做了测试,主要需求是只能预览不能下载,但对于前端来说,没有绝对的禁止,这里只罗列实现方式。
目前采用vue3版本为:3.2.37

  1. iframe
  2. vue-office
  3. pdfjs-dist

iframe

先说最简单的,iframe可以直接展示pdf文件,所以如果不作禁止预览等操作,iframe是最合适的。

    <el-dialogv-model="previewOtherUpload"reset-drag-positiondraggablesticky:title="_options.imgName || '详情'"footer-hideclass-name="vertical-center-modal"><div@contextmenu.preventstyle="user-select: none;"><iframeref="iframe":src="`${modelValue}#toolbar=0`"width="100%"height="600px"@load="onIframeLoad"></iframe></div></el-dialog><script setup>
const modelValue = ref('https://501351981.github.io/vue-office/examples/dist/static/test-files/test.pdf')
let previewOtherUpload = ref(false);
const iframe = ref(null)const clickShow = () => {previewOtherUpload.value = true;
}// 尝试在iframe加载完毕后,进行右键禁用,但实际需要通过postmessage来处理,所以这里无实际用处
const onIframeLoad = () => {try {console.log('iframe 已加载', iframe.value.contentWindow.window);if (iframe.value.contentWindow.document) {iframe.value.contentWindow.document.addEventListener('contextmenu', (e) => e.preventDefault());}} catch (error) {console.error('无法访问 iframe 内容:', error);}
}
</script>

在这里插入图片描述

vue-office

vue-office-gitcode地址

安装
#docx文档预览组件
npm install @vue-office/docx vue-demi@0.14.6#excel文档预览组件
npm install @vue-office/excel vue-demi@0.14.6#pdf文档预览组件
npm install @vue-office/pdf vue-demi@0.14.6#pptx文档预览组件
npm install @vue-office/pptx vue-demi@0.14.6如果是vue2.6版本或以下还需要额外安装 @vue/composition-api
npm install @vue/composition-api

我们如果只预览pdf,则安装 npm install @vue-office/pdf vue-demi@0.14.6

    <el-dialogv-model="previewOtherUpload"reset-drag-positiondraggablesticky:title="_options.imgName || '详情'"footer-hideclass-name="vertical-center-modal"><div@contextmenu.preventstyle="user-select: none;"><VueOfficePdf:src="modelValue"/></div></el-dialog><script setup>
import VueOfficePdf from '@vue-office/pdf'
const modelValue = ref('https://501351981.github.io/vue-office/examples/dist/static/test-files/test.pdf')
let previewOtherUpload = ref(false);const clickShow = () => {previewOtherUpload.value = true;
}
</script>

在这里插入图片描述

pdfjs-dist

这是目前最麻烦的一个插件,一定先确定下载的版本"pdfjs-dist": “2.16.105”,我用的是这个,否则下面的workerSrc设置会有问题。

  <el-dialogv-model="previewOtherUpload"reset-drag-positiondraggablesticky:title="_options.imgName || '详情'"footer-hideclass-name="vertical-center-modal"><div id="pdf-view"@contextmenu.preventstyle="user-select: none;"><canvas v-for="page in state.pdfPages" :key="page" id="pdfCanvas" /><div id="text-view"></div></div></el-dialog><script setup>
import { computed, reactive, ref, watch, nextTick } from "vue";
import * as pdfjsViewer from 'pdfjs-dist/web/pdf_viewer.js'
import 'pdfjs-dist/web/pdf_viewer.css'
import * as PDF from 'pdfjs-dist'
// 设置 pdf.worker.js 路径
PDF.GlobalWorkerOptions.workerSrc = '../../../node_modules/pdfjs-dist/build/pdf.worker.js';
let pdfDoc = null;const modelValue = ref('https://501351981.github.io/vue-office/examples/dist/static/test-files/test.pdf')
let previewOtherUpload = ref(false);const clickShow = () => {loadFile(modelValue)previewOtherUpload.value = true;
}const loadFile = (url) => {PDF.getDocument({url,cMapUrl: 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.16.105/cmaps/',cMapPacked: true,}).promise.then((pdf) => {pdfDoc = pdf// 获取pdf文件总页数state.pdfPages = pdf.numPagesnextTick(() => {renderPage(1) // 从第一页开始渲染})})
}
const renderPage = (num) => {pdfDoc.getPage(num).then((page) => {const canvas = document.getElementById('pdfCanvas')const ctx = canvas.getContext('2d')const viewport = page.getViewport({ scale: state.pdfScale })canvas.width = viewport.widthcanvas.height = viewport.heightconst renderContext = {canvasContext: ctx,viewport}page.render(renderContext)})
}
</script>

插件样式也不好调整,不推荐。

总结:
最后还是使用了第二种方式,作为禁止下载的展示。

http://www.hkea.cn/news/938113/

相关文章:

  • 外汇局网站做结汇申报被逆冬seo课程欺骗了
  • 网站运营配置免费网站在线观看人数在哪直播
  • 什么网站做一手房好系统优化的例子
  • wordpress 插入wordseo排名点击工具
  • 网站推广易网宣seo的主要分析工具
  • 安徽网站定制最大免费广告发布平台
  • 怎么查网站有没有做404公司宣传网页怎么做
  • 靠谱营销网站开发选哪家seo的优点和缺点
  • 企业网站建设论文文献综述百度推广的广告真实可信吗
  • 企业网站优化方式广州最新消息今天
  • 旅游网站开发的意义seo优化方案案例
  • 山东做网站的公司seo数据分析哪些方面
  • 做网站用哪几个端口 比较好百度贴吧官网网页
  • 弹幕网站是怎么做的百度在线翻译
  • 独立网站域名代发关键词包收录
  • 如何建立门户网站百度可以发布广告吗
  • 网站开发毕设文献郑州网站优化顾问
  • 青海建设银行的官方网站自己制作网页的网站
  • 网站建设的图片叠加步骤过程2021年搜索引擎排名
  • 网站链接到邮箱怎么做搜索引擎推广试题
  • 十堰城市建设网站制作自己的网站
  • 传媒网站建设公司深圳百度seo优化
  • 公司需要网站 该怎么做公司推广咨询
  • 高中男女做那个视频网站seo做的好的网站
  • 网站建设 摄影服务上海seo网站排名优化公司
  • 网页设计中html代码seo博客网站
  • 怎样建设小游戏网站google关键词搜索技巧
  • 淘宝 客要推广网站怎么做全媒体广告代理
  • 那个b2b网站可以做外贸武汉全网推广
  • 深圳css3网站开发多少钱如何策划一个营销方案