赞
踩
使用的网络请求框架是axios
ohpm install @ohos/axios
import axios, { FormData } from "@ohos/axios" import fs from '@ohos.file.fs' import ArrayList from '@ohos.util.ArrayList' /** * 网络请求工具类 */ class HttpManager { baseUrl:string /** * get请求 * @param url * @param param * @returns */ get(url: string, param: object) { this.init() return new Promise((resolve, reject) => { axios.get(url, { params: param }).then(function (response) { if (response.data == 200) { resolve(response.data) } else { reject(response.data) } }).catch(function (error) { reject(error.data) }) }) } /** * post请求 * @param url * @param params * @returns */ post(url: string, params: object) { this.in
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。