Comments (2)
可以这样解决
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.
在axios配置上,接口返回的是response.data。从配置上判断,response.data的数据格式应该是
{ code:200, msg:xxx, [具体数据的key]: 具体数据 }
在api文件里,具体接口定义的返回值类型是 ResourceOption,ResourceOption与response.data类型明显不一致,ResourceOption应该是
具体数据
的类型不知道我又没有理解错
对的,包括你下面理解的也是对的,因为这个东西数据格式需要根据的数据类型来具体配置,没考虑这么周全,我这边改一下
from vue3-ts-template-h5.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue3-ts-template-h5.