Javascript 如何使用ReactJS设置本地图像的宽度和高度
在图像库中显示之前,我想设置宽度和高度Javascript 如何使用ReactJS设置本地图像的宽度和高度,javascript,reactjs,Javascript,Reactjs,在图像库中显示之前,我想设置宽度和高度 import ap1 from './Images/ap1.jpg'; const images = [ {original: ap1, thumbnail: ap1}] 如何在{original:ap1,thumboil:ap1}中设置内部的宽度和高度?我将通过我的应用程序创建一个可重用组件: function PictureSizer ({img, height, width}) { return <img height={h
import ap1 from './Images/ap1.jpg';
const images = [ {original: ap1, thumbnail: ap1}]
如何在
{original:ap1,thumboil:ap1}
中设置内部的宽度和高度?我将通过我的应用程序创建一个可重用组件:
function PictureSizer ({img, height, width}) {
return <img height={height} width={width} src={img} alt="Type something descriptive" />
}
function PictureSizer({img,height,width}){
返回
}
然后,您可以使用所需的任何高度、宽度调用该组件:
import ap1 from './Images/ap1.jpg';
<PictureSizer img={ap1} height={50} width={50} />;
从“/Images/ap1.jpg”导入ap1;
;
plz,请不要删除您的问题:D谢谢。请给我一个答案,告诉我您如何使用“图像”?当您要显示图像时,必须使用img标签;您可以在标签上指定宽度和高度属性。我没有图像标签。。请注意,我的问题对我不起作用:-(函数PictureSizer({img,height,width}){return};const images=[{original:ap1,thumbnail:ap1}]我制作了一个与此概念相同的示例: