10年匠心专业提供互联网设计开发方案

原创设计 定制开发

满足您的个性化需求

对接下载类接口

对接下载接口时,需要对接口返回的进行处理
// 封装get请求
	GET(token,data,api,responseType){
		//参数
		let params = data
		// token请求头
		let headers = {}
		headers.Authorization = token
		return axios.get(api, {
			params,
			headers,
			responseType,
		  })
	},
 xiazaitupian(pictureUrl,id){
			 this.$Request.GET(sessionStorage.getItem('token'),{pictureUrl:pictureUrl},"/teamMember/" + id + "/picture",'blob').then(res=>{
				  // console.log("/teamMember/" + id + "/picture")
				  console.log(res)
				  if(res.data.status == 0){
					  this.$message({
						type: 'info',
						message: res.data.message
					  });
				  }
				  // 如果接口里有名字使用线面三行可以得到名字,没有就自己写一个吧
				  var content = res.headers["content-disposition"];
				  //var name = content && content.split(";")[1].split("filename=")[1];
				 // var fileName = decodeURIComponent(name);
				 
				 //文件名
				 var fileName = res.data.size;
				  var blob = new Blob([res.data], {
					  //这里是文件类型
				  	type: "image/jpeg;charset=utf-8;"
				  });
				  var downloadElement = document.createElement("a");
				  var href = window.URL.createObjectURL(blob);
				  downloadElement.href = href;
				  downloadElement.download = fileName;
				  document.body.appendChild(downloadElement);
				  downloadElement.click();
				  document.body.removeChild(downloadElement);
				  window.URL.revokeObjectURL(href);
				      
			  })
		  },

使用声明

1. 本站所有素材(未指定商用),仅限学习交流请勿用于商业用途。

2. 原创商用和VIP素材,未经合法授权,会员不得以任何形式发布、传播、复制、转售该素材,否则一律封号处理。

3. 如果素材损害你的权益请联系客服vx:13230981129给予处理。

热门标签

周明亮
微信扫一扫立即咨询
公众号
在线客服
在线联系
17330196230 13230981129 18830906230
顶部
账号登录|扫码登录

立即注册 |忘记密码?

欢迎注册

已有账号马上登录

重置密码

扫码绑定微信
微信扫一扫

绑定手机号