我正在尝试将图像从一个js文件导入另一个js文件。我的第一个js文件是函数组件Track.js。
import React from 'react'
import { screenimage, screenimage1 } from "./srcimages.js";
function Track() {
return (
<div>
Hello Component
<img src={screenimage} alt=""/>
<img src={screenimage1} alt=""/>
</div>
)
}
export default Track
我的第二个js文件是const image.js。
const screenimage = 'https://image.shutterstock.com/image-illustration/shopping-online-concept-modern-design-260nw-1934432345.jpg';
const screenimage1 = 'https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png';
我试图在一个js文件中创建多个映像源的集合,并将其作为img <img src={here}/>
属性导入。我尝试了上面的方法,但是它显示了src的空值。
UPDATE从这篇文章中删除标签"typoscript“
发布于 2021-09-01 03:58:24
您需要从image.js
文件导出图像。检查下面的代码:
export const screenimage = "https://image.shutterstock.com/image-illustration/shopping-online-concept-modern-design-260nw-1934432345.jpg";
export const screenimage1 = "https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png";
发布于 2021-09-01 03:56:20
因此,尝试将导出添加到const
后面
喜欢
export const screenimage = 'https://image.shutterstock.com/image-illustration/shopping-online-concept-modern-design-260nw-1934432345.jpg',
https://stackoverflow.com/questions/69013242
复制相似问题