我在try 从我的回购中渲染图片时遇到了问题. 我将组件的框架放在一个库中,并在不同的repo中呈现该组件,但我找不到在UI中显示图片的正确路径.
Here is my code for the component in the library:个
<ThemeProvider theme={buyingTheme}>
<Box display='flex' width='100%' justifyContent='center' alignItems='center'>
<Box display='flex' sx={{ height:'445px', width:'445px', border: '1px solid red' }}>
<Box
height='306px'
width='333px'
sx={{
paddingTop: '70px',
paddingLeft: '47px',
backgroundImage: `url(${picture})`,
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
backgroundSize: 'contain',
}}
>
{/* <img src={emptyStateLight} alt="Empty State" /> */}
</Box>
</Box>
<Box display='flex' flexDirection='column' alignItems='left' sx={{ height:'136px', width:'445px', border: '1px solid blue', marginLeft: '20px' }}>
<Typography variant="headings.h3" sx={{ height:'24px', paddingTop:'4px', paddingBottom:'4px' }}>{title}</Typography>
<Typography
variant="body.default"
color="text.secondary"
sx={{
whiteSpace: 'pre-line',
wordWrap: 'break-word',
marginTop: '4px', height:'48px',
paddingBottom:'4px', marginBottom: '4px',
}}
>
{description}
</Typography>
<Button
sx={{ height: '40px', width: '93px', padding:'20px', marginTop: 'auto' }}
onClick={handleOnClick}
>
{buttonText}
</Button>
</Box>
</Box>
</ThemeProvider>
Here is the code in the repo个
<EmptyState
picture="public/picture.png"
title="Title"
description="Description multi-line Description
multi-line Description
multi-line"
handleOnClick={() => {
// TODO: Define your click handler function here
}}
buttonText="Button"
/>
图片位于PUBLIC-->;PUBLIC\Picture.png文件夹中,我的组件位于-->;src\pages\Layout\CollectionsTable\CollectionsTable.tsx中
我如何修复问题并显示图片? 我try 了许多方法,但都没有成功.