Git Product home page Git Product logo

Comments (2)

Xyuan-abs avatar Xyuan-abs commented on June 19, 2024 1

可以这样解决

interface ResponseData<T> {
  code: number
  success: boolean
  data: T
}

interface ResourceOption{
  title:string;
  logo:string;
}

export const getResouceList = () => {
  return request<ResponseData<ResourceOption[]>>({
    url: "api/resource/list",
    method: "get"
  });
};

from vue3-ts-template-h5.

weizhanzhan avatar weizhanzhan commented on June 19, 2024

image

在axios配置上,接口返回的是response.data。从配置上判断,response.data的数据格式应该是

{
  code:200,
  msg:xxx,
  [具体数据的key]: 具体数据
}

image 在api文件里,具体接口定义的返回值类型是 ResourceOption,ResourceOption与response.data类型明显不一致,ResourceOption应该是具体数据的类型

不知道我又没有理解错

对的,包括你下面理解的也是对的,因为这个东西数据格式需要根据的数据类型来具体配置,没考虑这么周全,我这边改一下

from vue3-ts-template-h5.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.