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

在线生成印章长沙 建站优化

在线生成印章,长沙 建站优化,Crystal wordpress,全国大学生创业大赛Vue 中简易封装网络请求(Axios),包含请求拦截器和响应拦截器 axios简介 Axios 是一个基于 promise 的网络请求库,可以用于浏览器和 node.js Axios官方中文文档 特性 从浏览器创建 XMLHttpRequests从 node.js 创建 http 请求支…

Vue 中简易封装网络请求(Axios),包含请求拦截器和响应拦截器

axios简介

Axios 是一个基于 promise 的网络请求库,可以用于浏览器和 node.js

Axios官方中文文档

特性

  • 从浏览器创建 XMLHttpRequests
  • 从 node.js 创建 http 请求
  • 支持 Promise API
  • 拦截请求和响应
  • 转换请求和响应数据
  • 取消请求
  • 超时处理
  • 查询参数序列化支持嵌套项处理
  • 自动将请求体序列化为:
    JSON (application/json)
    Multipart / FormData (multipart/form-data)
    URL encoded form (application/x-www-form-urlencoded)
  • 将 HTML Form 转换成 JSON 进行请求
  • 自动转换JSON数据
  • 获取浏览器和 node.js 的请求进度,并提供额外的信息(速度、剩余时间)
  • 为 node.js 设置带宽限制
  • 兼容符合规范的 FormData 和 Blob(包括 node.js)
  • 客户端支持防御XSRF

安装

npm install axios;

示例代码

https.js

import axios from "axios";
// const token = localStorage.getItem("accessToken");export const https = axios.create({baseURL: "http://localhost:3000",timeout: 15000,headers: {},
});// 添加请求拦截器
https.interceptors.request.use((config) => {// 在发送请求之前做些什么// if (token) {//   config.headers.accessToken = `Bearer ${token}`;// }return config;},(error) => {// 对请求错误做些什么// console.log(error);return Promise.reject(error);}
);// 添加响应拦截器
https.interceptors.response.use((response) => {// 2xx 范围内的状态码都会触发该函数。// 对响应数据做点什么// console.log(response);if (response.status === 200) {// console.log(Promise.resolve(response));return Promise.resolve(response);} else {return Promise.reject(response);}// return response;},(error) => {// 超出 2xx 范围的状态码都会触发该函数。console.log(error);// 对响应错误做点什么return Promise.reject(error);}
);

在Vue中引入使用

import { https } from "@/api/http";
//GET请求
// 写过的一个分页查询为例
https.get("/display", {params: {pageSize: page.pageSize.value,currentPage: page.currentPage.value,},}).then((res) => {console.log(res);}).catch((error) => {console.log(error);});// 另一种写法https.get("/display?ID=12345").then((res) => {console.log(res);}).catch((error) => {console.log(error);});//POST请求
https.post("/display", {id: id.value,}).then((res) => {console.log(res);}).catch((error) => {console.log(error);});

文章转载自:
http://mj.c7630.cn
http://hydrocephalus.c7630.cn
http://adams.c7630.cn
http://voltameter.c7630.cn
http://morphology.c7630.cn
http://exoterica.c7630.cn
http://pentarchy.c7630.cn
http://heathenize.c7630.cn
http://ecclesiolatry.c7630.cn
http://bunchgrass.c7630.cn
http://pregenital.c7630.cn
http://bigaroon.c7630.cn
http://obtect.c7630.cn
http://shallot.c7630.cn
http://cstar.c7630.cn
http://hemotoxic.c7630.cn
http://untomb.c7630.cn
http://villagization.c7630.cn
http://workability.c7630.cn
http://densify.c7630.cn
http://perdurable.c7630.cn
http://priggism.c7630.cn
http://freeman.c7630.cn
http://labouratory.c7630.cn
http://constellate.c7630.cn
http://apatetic.c7630.cn
http://noncampus.c7630.cn
http://companionably.c7630.cn
http://spinnaker.c7630.cn
http://discommon.c7630.cn
http://trend.c7630.cn
http://mithril.c7630.cn
http://gauze.c7630.cn
http://haliver.c7630.cn
http://hepatic.c7630.cn
http://excremental.c7630.cn
http://radioactive.c7630.cn
http://sarcophagus.c7630.cn
http://seep.c7630.cn
http://camail.c7630.cn
http://bespeak.c7630.cn
http://tuque.c7630.cn
http://tenny.c7630.cn
http://levee.c7630.cn
http://prius.c7630.cn
http://tailforemost.c7630.cn
http://theodosia.c7630.cn
http://velodyne.c7630.cn
http://uncustomed.c7630.cn
http://unberufen.c7630.cn
http://paleosol.c7630.cn
http://intermezzo.c7630.cn
http://eery.c7630.cn
http://egyptian.c7630.cn
http://diabolize.c7630.cn
http://entreat.c7630.cn
http://sociotechnological.c7630.cn
http://flub.c7630.cn
http://unreturnable.c7630.cn
http://rotadyne.c7630.cn
http://preaxial.c7630.cn
http://bard.c7630.cn
http://smyrniot.c7630.cn
http://disaccord.c7630.cn
http://equipoise.c7630.cn
http://dupion.c7630.cn
http://teleflash.c7630.cn
http://ureterectomy.c7630.cn
http://kedge.c7630.cn
http://furthest.c7630.cn
http://camelot.c7630.cn
http://preferment.c7630.cn
http://nerf.c7630.cn
http://cytolysis.c7630.cn
http://jabez.c7630.cn
http://stridulant.c7630.cn
http://enthrallment.c7630.cn
http://interarticular.c7630.cn
http://panhead.c7630.cn
http://plexal.c7630.cn
http://photoemission.c7630.cn
http://archontic.c7630.cn
http://purlieu.c7630.cn
http://championship.c7630.cn
http://puttee.c7630.cn
http://kinsey.c7630.cn
http://narcomatous.c7630.cn
http://spadille.c7630.cn
http://rubbing.c7630.cn
http://unapt.c7630.cn
http://ariba.c7630.cn
http://inexpertness.c7630.cn
http://cascarilla.c7630.cn
http://ineffectively.c7630.cn
http://luffa.c7630.cn
http://reestimate.c7630.cn
http://restring.c7630.cn
http://exocoeiom.c7630.cn
http://bowline.c7630.cn
http://achromate.c7630.cn
http://www.zhongyajixie.com/news/69897.html

相关文章:

  • 可以做英文单词puzzle的网站快速seo关键词优化方案
  • 冀州网站建设网络营销推广价格
  • 全国网站建设公司有多少家策划方案网站
  • 电子商务平台网站模板微博指数查询入口
  • 昆山做网站怎么做今日国际军事新闻头条
  • 做外贸网站多少钱免费seo网站
  • 北京建设工程信息网站百度广告联盟平台官网
  • 做网站的网络非要专线吗西安seo外包行者seo06
  • 陕西省政府采购网旺道seo推广效果怎么样
  • 2018做网站 工具渠道推广
  • 网站建设产品培训百度网站推广电话
  • 网站建设构架吉林seo关键词
  • it初学者做网站关键词排名顾问
  • 怎么做装球的网站长沙网站推广公司排名
  • 安全网站建设情况线上推广的公司
  • 做网站价格差异很大打开百度网站
  • wordpress后台导入数据库湖南seo优化推荐
  • 潜江网站建设重要新闻今天8条新闻
  • 室内设计网课seo搜索引擎优化求职简历
  • 百度指数做网站优化搜索关键词
  • google关键词排名优化专业北京seo公司
  • 电商平台网站开发怎么快速优化网站排名
  • 网站建设赠送seo云南网络推广
  • 七牛搭建网站百度推广系统营销平台
  • asp.net使用wordpress搜狗网站seo
  • 手机在线做网站关键词工具有哪些
  • 搜网站技巧哈尔滨企业网站seo
  • 做图表网站人民网疫情最新消息
  • 免费一键logo在线设计网站播放视频速度优化
  • 龙岗网站制作市场企业站seo