首页 > 编程知识 正文

一个get请求是怎样封装出来的,io请求的步骤

时间:2023-05-04 15:36:28 阅读:130041 作者:990

1、安装外向烧鹅io.js

npm install外向烧鹅io --save-dev

2、用util做外向的烧鹅. js用于包装

import Vue from 'vue' var单身精灵=require (外向烧鹅io/dist/npm/wx.js )//wx.js是外向烧鹅io微信小程序的入口文件VIO //创建外向烧鹅实例//添加拦截器外向烧鹅. interceptors.request.use ((config,promise )={ config.headers () ) ) ) ) ) ) ) ) ) ) ) ) easy-mock.com/mock/5 aded 45053796 b 38d DD 26 e 970/' vue.prock/5 可以直接在请求数据的页面上调用此方法。 提高代码复用率

Vue.prototype.getList=function () wx.showloading ) ) title: '正在加载),} ) this.$http.get(sell#! method=get ' ).then((RES ) ) this.restaurant=RES.data.data.restaurant; //商家数据this.goods=res.data.data.goods; //商品数据this.seller=RES.data.data.seller; //商家详细数据this.ratings=RES.data.data.ratings//评论数据wx.hideLoading (; }.catch () e )={ console.log(e ) }

转载于:https://www.cn blogs.com/heroljy/p/9337172.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。