这是来自 Column.d.ts 的 PrimeVue ColumnSlots(缩短)
export interface ColumnSlots {
/**
* Custom body template.
* @param {Object} scope - body slot's params.
*/
body: (scope: {
/**
* Row data.
*/
data: any;
/**
* Column node.
*/
column: Column;
/**
* Column field.
*/
field: string;
/**
* Row index.
*/
index: number;
/**
* Whether the row is frozen.
*/
frozenRow: boolean;
}) => VNode[];
}
这是我的函数,我将从 ColumnSlots 接收正文类型
function myFunction(slotProps: Parameters<ColumnSlots["body"]>) {
const correctTypes = slotProps[0]
}
这是我目前拥有的,但 slotProps 应该是 CorrectTypes 的类型。
我将 slotProps 作为数组获取,我应该获取的是该数组成员的类型。
我如何用打字稿声明这一点?我是否以正确的方式处理这件事?我觉得我已经很接近了,但我也可能走错了路。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
嗯,我在写完问题后一分钟就这样做了,它成功了......
仍然不确定这是否是最好的方法,但无论如何我都会发布它,以防有人发现它有用。