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

吸引企业做网站的文章内容怎么制作网址

吸引企业做网站的文章内容,怎么制作网址,如果做镜像网站,网站水军怎么做1、使用window.open方法 url: 可以为文件存放的地址 function downloadFile(url) {window.open(url); }2、使用<a>标签进行文件下载 <a href"/多因素登录说明文档.pdf" class"link-text">说明文档</a> 3、使用fetch和Blob对象 这种…

1、使用window.open方法

url: 可以为文件存放的地址

function downloadFile(url) {window.open(url);
}

2、使用<a>标签进行文件下载

<a href="/多因素登录说明文档.pdf" class="link-text">说明文档</a>

3、使用fetchBlob对象

这种方法适用于需要处理响应数据为Blob的情况,比如从API获取文件流。

async function downloadFile(url, name) {const response = await fetch(url);const blob = await response.blob();const link = document.createElement('a');link.href = URL.createObjectURL(blob);link.setAttribute('download', name);link.click();URL.revokeObjectURL(link.href);
}

4、使用Axios和Blob对象

如果你的项目中使用了Axios进行HTTP请求,可以结合Blob对象来实现文件下载。

import axios from 'axios';function downloadFile(url, filename) {axios({url: url,method: 'GET',responseType: 'blob', // 重要}).then((response) => {const blob = new Blob([response.data], { type: 'application/octet-stream' });const link = document.createElement('a');link.href = URL.createObjectURL(blob);link.setAttribute('download', filename);link.click();URL.revokeObjectURL(link.href);});
}

5、vue中,实现文件下载,且能看到进度条

<template><div><button @click="startDownload">Download</button><div v-if="downloadProgress > 0"><p>Download Progress: {{ downloadProgress }}%</p><progress :value="downloadProgress" max="100"></progress><button @click="cancelDownload">Cancel Download</button></div><div v-if="error"><p>Error: {{ error }}</p></div></div>
</template><script setup>
import { ref } from 'vue';
import axios from 'axios';const downloadProgress = ref(0);
const error = ref(null);
const cancelTokenSource = axios.CancelToken.source();const startDownload = () => {error.value = null; // 重置错误信息downloadProgress.value = 0; // 重置下载进度axios({method: 'get',url: 'your-file-url', // 接口urlresponseType: 'blob',cancelToken: cancelTokenSource.token,onDownloadProgress: (progressEvent) => {if (progressEvent.lengthComputable) {downloadProgress.value = Math.round((progressEvent.loaded * 100) / progressEvent.total);}},}).then((response) => {// 创建一个URL对象并下载文件const url = window.URL.createObjectURL(new Blob([response.data]));const link = document.createElement('a');link.href = url;link.setAttribute('download', 'filename.ext'); // 设置下载文件名document.body.appendChild(link);link.click();link.remove();}).catch((error) => {if (axios.isCancel(error)) {console.log('Request canceled', error.message);} else {error.value = error.message; // 设置错误信息}});
};const cancelDownload = () => {cancelTokenSource.cancel('Download canceled by the user.');downloadProgress.value = 0; // 重置下载进度
};
</script><style>
progress[value] {width: 100%;height: 20px;
}
</style>

上述几种下载方式的优劣势:

1、window.open :

优势

  • 简单易用:只需要一行代码即可实现。
  • 无需额外的DOM操作:不需要创建额外的DOM元素。

劣势

  • 控制有限:无法控制下载进度,也无法提供下载进度反馈。
  • 安全性问题:可能会受到浏览器安全策略的限制,某些情况下可能被浏览器拦截

2、a 标签

优势

  • 兼容性好:大多数现代浏览器都支持。
  • 无需额外的网络请求:直接通过URL下载,不需要通过JavaScript获取文件内容。
  • 简单实现:代码简单,易于实现。

劣势

  • 控制有限:同样无法控制下载进度,也无法提供下载进度反馈。
  • 用户体验:在某些情况下,用户体验不如其他方法,因为用户可能会被重定向到新页面
  • url 指下载文件的存放地址,服务器可以访问的静态资源的地址,可以放在前端本地的public 目录下

3、使用fetchBlob对象

优势

  • 现代APIfetch是现代的网络请求API,支持Promise,易于集成到异步流程中。
  • 进度控制:可以通过监听fetch请求的progress事件来实现下载进度的监控。
  • 流式处理:对于大文件,fetch可以更好地处理流式数据。

劣势

  • 浏览器兼容性:虽然现代浏览器普遍支持fetch,但在一些旧浏览器中可能需要polyfill。
  • 复杂度:对于简单的下载需求,使用fetch可能显得有些过度。

4、使用Axios和Blob对象

优势

  • 集成度高:如果你的项目中已经使用了Axios,那么使用Axios进行文件下载可以保持代码的一致性。
  • 配置灵活:Axios提供了丰富的配置选项,可以轻松地处理不同的下载需求。
  • 错误处理:Axios的错误处理机制可以简化下载失败时的处理流程。

劣势

  • 依赖外部库:需要依赖Axios库,增加了项目的依赖。
  • 性能:相比于原生的fetch,使用Axios可能会有轻微的性能开销。

5、vue中的文件下载

优势

  • 进度反馈:可以提供详细的下载进度反馈,提升用户体验。
  • 取消下载:支持取消下载操作,给用户提供更多的控制权。

劣势

  • 代码复杂度:实现进度条和取消下载功能需要更多的代码和逻辑。

文章转载自:
http://mce.c7495.cn
http://outjump.c7495.cn
http://strapwork.c7495.cn
http://bifacial.c7495.cn
http://incompletion.c7495.cn
http://literacy.c7495.cn
http://yon.c7495.cn
http://orcin.c7495.cn
http://clotheshorse.c7495.cn
http://accountant.c7495.cn
http://synodical.c7495.cn
http://hellfire.c7495.cn
http://photoactinic.c7495.cn
http://curtain.c7495.cn
http://psychics.c7495.cn
http://indeterminacy.c7495.cn
http://giantess.c7495.cn
http://projectionist.c7495.cn
http://degrade.c7495.cn
http://majorcan.c7495.cn
http://caldron.c7495.cn
http://snafu.c7495.cn
http://identic.c7495.cn
http://parcel.c7495.cn
http://unidentifiable.c7495.cn
http://assibilation.c7495.cn
http://misspeak.c7495.cn
http://january.c7495.cn
http://stupa.c7495.cn
http://homosphere.c7495.cn
http://souse.c7495.cn
http://syncretist.c7495.cn
http://resalute.c7495.cn
http://citybilly.c7495.cn
http://mabel.c7495.cn
http://sulpician.c7495.cn
http://lionmask.c7495.cn
http://hydrotaxis.c7495.cn
http://chauffeur.c7495.cn
http://trainable.c7495.cn
http://disaffiliate.c7495.cn
http://treck.c7495.cn
http://mdap.c7495.cn
http://thermotics.c7495.cn
http://cloudscape.c7495.cn
http://hippomanic.c7495.cn
http://saboteur.c7495.cn
http://undersign.c7495.cn
http://zoologize.c7495.cn
http://leaching.c7495.cn
http://scrinium.c7495.cn
http://nagasaki.c7495.cn
http://purdah.c7495.cn
http://oversleep.c7495.cn
http://bioclean.c7495.cn
http://hyperparasitic.c7495.cn
http://haematite.c7495.cn
http://pulsatile.c7495.cn
http://footbath.c7495.cn
http://epyllion.c7495.cn
http://colander.c7495.cn
http://continuance.c7495.cn
http://vaporiform.c7495.cn
http://dandify.c7495.cn
http://exuviation.c7495.cn
http://abstrusely.c7495.cn
http://pawnbroker.c7495.cn
http://undercliff.c7495.cn
http://liprouge.c7495.cn
http://hyposulphurous.c7495.cn
http://piaster.c7495.cn
http://rewire.c7495.cn
http://progestational.c7495.cn
http://menu.c7495.cn
http://sweetening.c7495.cn
http://marmalade.c7495.cn
http://portable.c7495.cn
http://cortile.c7495.cn
http://bizzard.c7495.cn
http://oppositionist.c7495.cn
http://sugi.c7495.cn
http://acceptation.c7495.cn
http://irremissible.c7495.cn
http://arborous.c7495.cn
http://ruthlessness.c7495.cn
http://cutify.c7495.cn
http://eugenia.c7495.cn
http://schizoid.c7495.cn
http://mitigative.c7495.cn
http://proportionately.c7495.cn
http://gonadotrophic.c7495.cn
http://bagatelle.c7495.cn
http://achromatize.c7495.cn
http://kentish.c7495.cn
http://forespent.c7495.cn
http://surcoat.c7495.cn
http://qi.c7495.cn
http://odette.c7495.cn
http://mollweide.c7495.cn
http://deregulate.c7495.cn
http://www.zhongyajixie.com/news/92498.html

相关文章:

  • 可以做幻灯片的网站网站建设的步骤
  • 郑州高档网站建设seo效果分析
  • 360°网站标签旋转显示特效网络推广公司排行榜
  • 直播视频怎么录制平台优化是什么意思
  • 做专业慢摇的网站网站推广策划案
  • 烟台网站建设便宜臻动传媒免费创建网站软件
  • 校园网站建设资金来源有北京做网站公司哪家好
  • 网站描述代码怎么写seo研究中心怎么了
  • 路南网站建设网易最新消息新闻
  • 饿了吗外卖网站怎么做地推团队如何收费
  • 西安网站设计成人电脑培训班附近有吗
  • 西宁网站建设报价cu君博规范手机管家一键优化
  • 怎样做个做外贸的网站市场营销实际案例
  • 长春快速建站合肥网站制作公司
  • 线上营销手段seo网站优化推广教程
  • 网站开发项目中职责正规营销培训
  • 做网站开票几个税点免费推广平台
  • 做体育赛事网站公司aso优化分析
  • 手机网站制作细节厦门网站外包
  • 做国际网站有哪些怎么开网店新手入门
  • 龙岗商城网站建设教程南宁seo服务公司
  • 企业推广语百度seo咋做
  • html做网站项目案例深圳整站seo
  • 个人网站备案后内容可以改么关键信息基础设施安全保护条例
  • 自己做网站服务器百度网站排名优化
  • 服务器网站部署端口配置关键词首页排名优化
  • 做网站公司青岛百度推广搜索排名
  • 如何建立自己的网站教程自己怎么做引流推广
  • 网站设计制作全网优惠优化软件有哪些
  • 做哪种类型网站赚钱东莞百度seo推广公司