1

TS+Axios 能指定解析的对象吗

 1 year ago
source link: https://www.v2ex.com/t/882636
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

TS+Axios 能指定解析的对象吗

  hldevelop369 · 12 小时 16 分钟前 · 664 次点击

我以前是 Android 开发的后台返回的 Json:{ "id":1, "name":"age" } 我在 android 中我定义一个 Bean ,我把 id 的类型定义成 String,我解析出来我用的时候就是 String 。 我发现我在 TS+Axios 中,这是我定义的 Bean export interface CategoryData { id?: string

name?: string

parent?: string

sort?: string children?: CategoryData[] }

id 定义为 string 我得到的数据依然是 number 。 研究了好多都没有发现怎么解决这个问题, 有没有大佬指点 1.2


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK