几天前,我刚刚开始使用Graphql / Apollo,今天遇到了这个问题。我有一个很大的导航栏,每个链接都有图标。有我的代码:
let nav_options = [
{
name: 'Dashboard',
image: 'pictures/icons/dashboard.png',
link: '/#'
},
{
name: 'Report',
image: './pictures/icons/dashboard.png',
link: '/#'
},
]
然后
export const Routes = () => (
<Router>
<div class="app-container">
<nav class="main-menu">
<ul>
{nav_options.map(option => (
<li>
<Link to={option.link}>
<input className="icon" type="image" src={option.image} />
<span class="nav-text">
{option.name}
</span>
</Link>
</li>
))}
{option.name}和{option.link}可以正常工作。我觉得我想念什么。?
我已修正问题:这就是方法
image: require('pictures/icons/dashboard.png'),
答案 0 :(得分:0)
您需要输入或导入图像。
let nav_options = [
{
name: 'Dashboard',
image: require('pictures/icons/dashboard.png'),
link: '/#'
},
{
name: 'Report',
image: require ('./pictures/icons/dashboard.png'),
link: '/#'
},
]