[英]Argument of type 'string[]' is not assignable to parameter of type 'string'
Have an array called categoryImages that I'm trying to pass into a function, and get the following error:有一个名为 categoryImages 的数组,我试图将它传递给一个函数,并得到以下错误:
"Argument of type 'string[]' is not assignable to parameter of type 'string'". “'string[]' 类型的参数不能分配给 'string' 类型的参数”。
const getLink = (
groupCode: string,
groupDisplayName: string,
groupCount?: number,
groupImage?: string
)
const categoryImages = [
attachmentImage,
compactorImage,
telehandlerImage,
backhoeLoaderImage,
excavatorImage,
wheelLoaderImage,
compactTrackLoaderImage,
skidSteerLoaderImage,
];
} else if (Constants.isEnvironmentBFE) {
count++;
const newLink = getLink(
// Grabbing API values
group["group-code"],
group["group-display-name"],
group.count,
// Load in local images
categoryImages // <-- throws error here
);
categoryList[column].push(newLink);
endColumnCheck(count);
}
I basically want to output this array of images, into the DOM.我基本上想将这个图像数组输出到 DOM 中。
You've said that the “getLink” function takes an argument “groupImage” which is a single image, But when you call the function you are giving it an array of images “categoryImages”.你已经说过“getLink”函数接受一个参数“groupImage”,它是一个单一的图像,但是当你调用这个函数时,你给它一个图像数组“categoryImages”。
You can:你可以:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.