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

google网站地图格式seo是什么服务

google网站地图格式,seo是什么服务,七牛怎么做网站服务器,wordpress文艺主题1. 创建实例 使用 axios.create() 使用自定义配置创建一个 axios 实例。 const $http axios.create({timeout: 1000,headers: {Content-Type: application/json,} })2. 拦截器 在请求或响应被 then 或者 catch 处理前拦截他们,拦截分为请求拦截和响应拦截。 //…

1. 创建实例

使用 axios.create() 使用自定义配置创建一个 axios 实例。

const $http = axios.create({timeout: 1000,headers: {'Content-Type': 'application/json',}
})

2. 拦截器

在请求或响应被 then 或者 catch 处理前拦截他们,拦截分为请求拦截和响应拦截。

// 添加请求拦截器
$http.interceptors.request.use(function (config) {// 在发送请求之前做些什么return config;}, function (error) {// 对请求错误做些什么return Promise.reject(error);});// 添加响应拦截器
$http.interceptors.response.use(function (response) {// 对响应数据做点什么return response;}, function (error) {// 对响应错误做点什么return Promise.reject(error);});

2.1 request 拦截器,全局添加市场信息

$http.interceptors.request.use(config => {......// 市场编码if (config.data && Object.prototype.toString.call(config.data) === '[object Object]' && typeof config.data !== 'string') {if (!config.data.removeMarketCode) {const market = store.state.common.market || {}config.data.marketId = market.keyconfig.data.marketName = market.val} else {delete config.data.removeMarketCode}}return config
}, error => {// Do something with request errorPromise.reject(error)
})
  • removeMarketCode 是否移除市场信息,默认不移除;

根据上述代码可以看到,市场信息都是默认添加在 config.data 对象中下的,如果我们需要调整传参对象的位置时,那需要更改上述逻辑,具体代码如下:

if (!config.data.removeMarketCode) {// 指定 data 下某个路径const key = config.data?.targetconst market = store.state.common.market || {}const marketObj = { marketId: market.key, marketName: market.val }if (key) {config.data[key] = { ...config.data[key], ...marketObj }delete config.data.target} else {config.data = { ...config.data, ...marketObj }}
} else {delete config.data.removeMarketCode
}

使用如下:

class BillManage {export (params) {return axios.post(URL.receivePayBill.export, { ...params, target: 'condition' })}
}
export default new BillManage()// 实际传参
{ "columns": [...], "condition": { "isPay": false, "marketId": "000", "marketName": "白糖" } }

2.2 response 拦截器

通过响应拦截器我们用来处理响应异常的接口进行拦截提示,返回对象中会返回一个 succeed 字段来表示接口处理正常还是异常情况,当然也有可能直接返回文件流,因此这里使用的 ‘succeed’ in res 的写法来表示 res 中是否存在 succeed 的 key 来代替 res.succeed。

// response 拦截器
$http.interceptors.response.use(response => {......const res = response.dataif ('succeed' in res && res.succeed !== true) {notification.error({message: 'Error',description: res.errorMsg,})return Promise.reject(new Error(res.errorMsg || 'error'))} else {return response.data}},error => {return Promise.reject(error)}
)

导出文件里处理如下:

class ReceivePayAccountManage {// 下载模板payOrderImportTmpl (params) {return axios.post(URL.receivePayOrder.payOrderImportTmpl, params, { responseType: 'blob' })}
}
export default new ReceivePayAccountManage()handleDownload (methodName) {handleRepeatSubmit.call(this, null, () => config.methods[methodName].handler(), (data) => downloadPDF('应付单导入模板.xlsx', data))
},

downloadPDF 方法传入文件名和文件流,下载文件信息处理,具体代码如下:

export const downloadPDF = function (fileName, blob) {const downloadElement = document.createElement('a')const href = window.URL.createObjectURL(blob)downloadElement.href = hrefdownloadElement.download = fileNamedocument.body.appendChild(downloadElement)downloadElement.click()document.body.removeChild(downloadElement)window.URL.revokeObjectURL(href)
}
http://www.ds6.com.cn/news/75409.html

相关文章:

  • 企业网站需求方案西安网站建设方案优化
  • 乐之网站制作百度账号登录入口官网
  • 网站建设就业方向百度收录网站提交入口
  • 前端做网站都要做哪些宁波seo网络推广定制
  • 零基础wordpress 知乎优化方案的格式及范文
  • 湖南城乡建设厅网站友链互换平台推荐
  • 32岁学做网站广州网络营销推广
  • 企业电子商务网站建设评估试验百度竞价关键词怎么优化
  • 中英文网站怎么做的五行seo博客
  • 天水有做网站的地方吗2022最近的新闻大事10条
  • 做网站的技术路线网站查询域名ip
  • 企业网站建设方案范本网络营销方法有哪些举例
  • 网站开发兼职群seo定义
  • 品牌网站建设公司排名提升神马关键词排名报价
  • 怎样在网站上做销售如何建网站详细步骤
  • 用旧电脑做服务器建网站用新闻热点素材
  • 商贸办公网站入口百度快速优化排名软件
  • 在腾讯云怎样建设网站市场调研报告怎么写
  • 网页设计尺寸pt是什么意思朝阳seo搜索引擎
  • 旅游网网站建设如何搭建网站平台
  • 费用网站建设seo怎么优化
  • 个人网站开发与设计摘要seo关键词排名技术
  • 人力资源外包灵活用工如何做网站优化
  • 网站收录入口申请西安seo优化推广
  • 福州网站建设推广平台搜索引擎优化分析
  • wordpress文章美观google seo教程
  • 制作网站首页可以打广告的平台
  • 建设银行网站-公司机构客户长春网络科技公司排名
  • 做内贸的网站百度首页广告
  • 苏州网页制作设计搜索引擎优化的目标