在Vue 3.3中,我将一个TS对象发送给一个axios方法,我在IDE中遇到了一个错误,这个错误对我来说没有意义。
Volar: Argument of type 'Ref{ all: boolean; beginner: boolean; advanced: boolean;
intermediate: number[]; go: boolean; docker: boolean; gcp: boolean; java: boolean;
vue: boolean; serverless: boolean; amqp: boolean; databases: boolean; mux: boolean;
grpc: boolean; spring: boolean; }>' is not assignable to parameter of type 'IFilter'.
Type 'Ref{ all: boolean; beginner: boolean; advanced: boolean; intermediate:
number[]; go: boolean; docker: boolean; gcp: boolean; java: boolean; vue: boolean;
serverless: boolean; amqp: boolean; databases: boolean; mux: boolean; grpc: boolean;
spring: boolean; }>' is missing the following properties from type 'IFilter': all,
beginner, advanced, intermediate, and 11 more.
字符串
在我称为axios示例的组件中
const f = ref<IFilter>({
advanced: false,
all: true,
amqp: false,
beginner: false,
databases: false,
docker: false,
gcp: false,
go: false,
grpc: false,
intermediate: [],
java: false,
mux: false,
serverless: false,
vue: false,
spring: false
});
api.getAll(1,6, f).then(c => courses.value = c)
型
然后在api.ts
中
async getAll(page: number, pageSize: number, filter?: IFilter): Promise<Course[]> {
const res = await request.get<{data: Course[], metadata: 'none'}>("/v1/courses", {
params: {
page: page,
pageSize: pageSize,
},
data: filter,
})
return res.data.data
},
型
1条答案
按热度按时间nwlls2ji1#
你需要通过.value调用它:
字符串