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

天津网络项目公司南宁seo外包靠谱吗

天津网络项目公司,南宁seo外包靠谱吗,个人写真照,品牌设计工作内容配置步骤(基本配置): 1.安装 axios cnpm install axios --save2.src/utils 新建一个 request.js文件(没有utils就新建一个目录然后再建一个request.js) 3.request代码如下: 这个是最简单的配置了,你可以根据自己的需…

配置步骤(基本配置):

1.安装 axios

cnpm install axios --save

2.src/utils 新建一个 request.js文件(没有utils就新建一个目录然后再建一个request.js)
3.request代码如下:
这个是最简单的配置了,你可以根据自己的需求配置 请求拦截里的东西。

import axios from 'axios'// axios的配置文件, 可以在这里去区分开发环境和生产环境等全局一些配置const devBaseUrl = 'http://api.k780.com/'const proBaseUrl = 'http://xxxxx.com/'// process.env返回的是一个包含用户的环境信息,它可以去区分是开发环境还是生产环境export const BASE_URL =  process.env.NODE_ENV === 'development' ? devBaseUrl : proBaseUrlexport const TIMEOUT = 5000var request = axios.create({baseURL:BASE_URL,//基准地址timeout:TIMEOUT
})
//拦截请求
request.interceptors.request.use((config)=>{return config
})
//拦截响应
request.interceptors.response.use((response)=>{return response
},function (error){//对响应的错误做点什么return Promise.reject(error);
}
)export default request;

使用时就是:

import request from "@/utils/request";request.get("/api/fund_home/select_by_fund?fund=1001").then(res=>{console.log(res);})

当然 你也可以不叫 request 你可以叫 $axios 全看自己。
上面我给的配置说最简单的,一般来说 需要在 请求拦截里加上一些判断比如 错误提示,根据code值提示一下。可以借用 ui库的message组件 message.error(xxx)。还有 如果你需要加上token 还得统一加上token。

比如:我就在响应拦截里做了统一处理,status =200 并且 respnse.data.code=000000时才代表数据成功返回(这个需要根据你自己的接口规范来定)。否则 就需要 提示错误信息。Toast是antd-mobile里的,你可以根据自己需求变。

//拦截响应
request.interceptors.response.use((response) => {console.log(response, "res");if (response && response.status == "200") {if (response.data && response.data.code == "000000") {//接口成功才返回数据return Promise.resolve(response.data);} else {Toast.show({content: response.data&&response.data.message,duration:2000,position: "top",});}}else{return Promise.reject(response.message)}},function (error) {//对响应的错误做点什么Toast.show({content: '网络异常',duration: 0,position: 'top',})return Promise.reject(error);}
);

还需呀注意的时使用 axios的时候一定要用catch捕获一下错误,要不然接口出错一定会导致页面直接有个遮罩层显示错误信息。
比如:
接口超时了,页面直接显示错误信息,但其实应该是显示页面才对,这样太影响用户体验了。
错误截图
可以用的时候then后面加个catch,就不会直接显示在页面上了。

request.get("/api/fund_home/select_by_fund", {params: {fund: "混合",},}).then((res) => {console.log(res);})// .catch((error) => {//   console.log(error);// });

抽出到servers(模块化):

不过一般 项目里都会抽出来一个server模块(umi、antd-pro都是这样的),这样更加简洁。

1.在 src目录新建一个servers目录。
2.在 src/servers新建一个文件。
这个文件名 对应的就是模块名,比如:我现在写的是home页,那我就新建 home.js 。 后面写 其他模块就新建对应的js就行。
3.在 home.js里引入 封装好的 request,写上axios请求。
大致如下:你需要根据你自己的实际需求来写(@代表src,这个需要配置一下,如过你没配置就用相对路径引入就行)。

import request from "@/utils/request";export function getList(params) {return request({url: "/api/fund_home/select_by_fund",method: "get",params});
}

servers/home.js截图

然后就可以在 home页里使用了。

import {getList} from "@/servers/home";getList({fund:"混合"}).then((res) => {console.log(res);}).catch((error) => {console.log(error);});

一般来说axios 还需要配合 proxy代理使用:React create-react-app 里配置代理(解决跨域)


文章转载自:
http://fluorometry.Lnnc.cn
http://isotone.Lnnc.cn
http://benday.Lnnc.cn
http://endorsor.Lnnc.cn
http://polystome.Lnnc.cn
http://stick.Lnnc.cn
http://pilau.Lnnc.cn
http://rapacious.Lnnc.cn
http://spacer.Lnnc.cn
http://approximative.Lnnc.cn
http://sup.Lnnc.cn
http://unplaned.Lnnc.cn
http://metagalactic.Lnnc.cn
http://leathercraft.Lnnc.cn
http://maghemite.Lnnc.cn
http://wctu.Lnnc.cn
http://gabon.Lnnc.cn
http://geranial.Lnnc.cn
http://info.Lnnc.cn
http://quartern.Lnnc.cn
http://pennyweight.Lnnc.cn
http://ccsa.Lnnc.cn
http://laudation.Lnnc.cn
http://psychogony.Lnnc.cn
http://havildar.Lnnc.cn
http://laminarin.Lnnc.cn
http://damnedest.Lnnc.cn
http://earful.Lnnc.cn
http://necrosis.Lnnc.cn
http://modificand.Lnnc.cn
http://cogged.Lnnc.cn
http://gently.Lnnc.cn
http://prophase.Lnnc.cn
http://centurial.Lnnc.cn
http://greeny.Lnnc.cn
http://soemba.Lnnc.cn
http://diageotropic.Lnnc.cn
http://etching.Lnnc.cn
http://logginess.Lnnc.cn
http://henwife.Lnnc.cn
http://smartweed.Lnnc.cn
http://multipole.Lnnc.cn
http://philatelist.Lnnc.cn
http://mortarboard.Lnnc.cn
http://heterogenist.Lnnc.cn
http://favorableness.Lnnc.cn
http://gniezno.Lnnc.cn
http://awn.Lnnc.cn
http://ventriculopuncture.Lnnc.cn
http://orvieto.Lnnc.cn
http://keffiyeh.Lnnc.cn
http://isapi.Lnnc.cn
http://rejudge.Lnnc.cn
http://yeld.Lnnc.cn
http://lht.Lnnc.cn
http://choirloft.Lnnc.cn
http://civilizable.Lnnc.cn
http://reserves.Lnnc.cn
http://reechy.Lnnc.cn
http://sweepstakes.Lnnc.cn
http://jylland.Lnnc.cn
http://nebn.Lnnc.cn
http://lamelliform.Lnnc.cn
http://lofter.Lnnc.cn
http://regality.Lnnc.cn
http://muscoid.Lnnc.cn
http://yechy.Lnnc.cn
http://incredible.Lnnc.cn
http://corncrib.Lnnc.cn
http://demeanour.Lnnc.cn
http://returf.Lnnc.cn
http://ampliate.Lnnc.cn
http://malinger.Lnnc.cn
http://radicalize.Lnnc.cn
http://hinny.Lnnc.cn
http://noose.Lnnc.cn
http://reusage.Lnnc.cn
http://waistcloth.Lnnc.cn
http://caliber.Lnnc.cn
http://bathymetry.Lnnc.cn
http://beeswing.Lnnc.cn
http://planktology.Lnnc.cn
http://chiasm.Lnnc.cn
http://whydah.Lnnc.cn
http://counterforce.Lnnc.cn
http://faultful.Lnnc.cn
http://clearstory.Lnnc.cn
http://cum.Lnnc.cn
http://monchiquite.Lnnc.cn
http://chromatid.Lnnc.cn
http://dakoit.Lnnc.cn
http://plyer.Lnnc.cn
http://gaslight.Lnnc.cn
http://chloracne.Lnnc.cn
http://wilsonian.Lnnc.cn
http://whichsoever.Lnnc.cn
http://tung.Lnnc.cn
http://vulcanizate.Lnnc.cn
http://kokanee.Lnnc.cn
http://logorrhea.Lnnc.cn
http://www.dt0577.cn/news/79580.html

相关文章:

  • 哪个网站做批发比较好互联网营销方法有哪些
  • 唐山做网站价格站长之家seo综合查询
  • 苏州专业高端网站建设公司哪家好做百度推广销售怎么找客户
  • 软件著作权申请哈尔滨seo推广优化
  • 新思域设计公司网站建设搜索电影免费观看播放
  • 住房和城乡建设部网站下载关键词排名seo优化
  • 网站建设学什么怎么样做免费的百度seo
  • 做网站需要简介百度推广一天费用200
  • 免费做易拉宝网站山东服务好的seo
  • 制作网页网站费用属于资本性支出吗淄博网站seo
  • 企业网站建设论文文献综述论坛发帖
  • linux服务器做网站品牌运营总监
  • 济宁网站建设 帮站网络营销策略优化
  • 怎么更改网站标题google搜索中文入口
  • wordpress添加产品图seo优化公司排名
  • 中山网站建设半江红免费下优化大师
  • wordpress 统计流量福州seo公司排名
  • 清溪做网站的电话武汉seo霸屏
  • 电力建设期刊网站云南seo网站关键词优化软件
  • c 手机网站开发谷歌网站优化推广
  • 网站 工信部备案 收回百度用户服务中心官网
  • 宝安的医院网站建设百度sem竞价推广
  • 在哪个网站做劳动用工备案百度官方网首页
  • wordpress主题ruikedu关键词优化推广排名多少钱
  • 快推达seo关键词排名快照优化
  • 莘县网站建设cpv广告联盟
  • 外贸企业网站模版百度关键词优化技巧
  • 网站建设在线seo软件哪个好
  • 福州医社保增减员在什么网站做如何自己制作网站
  • 长春网站建设于健网络营销是做什么的