type _data = {
citemName: string;
cstatus: number;
cplanStartTime: string;
cplanEndTime: string;
creleasedQty: number;
clevelName: string;
cplanQty: number;
ccompletedQty: number;
citemNo: string;
clevel: string;
cscrapQty: number;
citemId: string;
cstatusName: string;
cmoCode: string;
citemSpec: string;
id: string;
cid: string;
}
type IRootType = {
total: number;
code: string;
data: _data[];
success: boolean;
}
data() {
return {
dataList: [] as _data[],
page: 1,
imit: 10
};
},
图1是报错内容,图2是接口返回的数据格式。代码里定义了dataList类型,请求方法也定义type类型,但还是报错。
acoolfish (作者)
你好,代码里dataList定义的类型也没问题吧
2024-06-18 11:53
大饼
回复 acoolfish: dataList: [] as _data[]|null data对象定义改成这个试试。
2024-06-18 16:04