Das ist PrimeVue ColumnSlots (gekürzt) von Column.d.ts
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[]; }
Das ist meine Funktion, ich erhalte den K?rpertyp von ColumnSlots
function myFunction(slotProps: Parameters<ColumnSlots["body"]>) { const correctTypes = slotProps[0] }
Das ist es, was ich derzeit habe, aber slotProps
應(yīng)該是 CorrectTypes
der Typ.
Ich erhalte SlotProps als Array. Was ich erhalten sollte, ist der Typ des Array-Mitglieds.
Wie erkl?re ich das im Typoskript? Gehe ich richtig damit um? Ich habe das Gefühl, dass ich ziemlich nah dran bin, aber vielleicht bin ich auf dem falschen Weg.
嗯,我在寫完問題后一分鐘就這樣做了,它成功了......
仍然不確定這是否是最好的方法,但無論如何我都會(huì)發(fā)布它,以防有人發(fā)現(xiàn)它有用。
function myFunction(slotProps: Parameters) { const correctTypes = slotProps }