Ran*_*zer 5 javascript user-interface frontend reactjs ant-design-pro
我正在尝试创建一个列,在他的条目中将包含一张小图片和一个名称。我怎样才能使用 Ant Design 的表格来做到这一点?
https://ant.design/components/table/ 我似乎在文档或示例中找不到任何相关内容。
如果您以与其文档中显示的示例类似的方式使用该表。(使用数据源数组)
你可以做这样的事情
const columns = [
{
title: '',
dataIndex: 'image_URL_here',
render: () => <img src={`image_URL_here`} />
}
]
Run Code Online (Sandbox Code Playgroud)
接受的答案中有一个错误,这里是你怎么做的
{
title: "Image",
dataIndex: "ImageURL", // this is the value that is parsed from the DB / server side
render: theImageURL => <img alt={theImageURL} src={theImageURL} /> // 'theImageURL' is the variable you must declare in order the render the URL
}
Run Code Online (Sandbox Code Playgroud)
您需要声明theImageURL,然后将其与altand一起使用src。