尝试将“s”字符串添加到样式组件中传递的道具时遇到问题。另外,我不完全确定我是否可以prop.x
在样式组件中使用。这就是我的意思:
const MyComponent = (props) => {
const StyledLineItem = styled.li`
animation: ${someAnime};
animation-delay: ${props.x}; // <- will this work?
// here i need to add the 's' to the end
// but i can't use `` becaouse of the fact that styled components
// are in a template tag already... at least i think that's why
// i get errors when i try `${props.x}s`
// also, i haven't tested but will using ${prop.x} in a styled-component
// like this even work?
`
return (
<StyledLineItem>{props.text}</StyledLineItem>
)
}
// in my main component...
// ... react component stuff
render() {
return (
<ul>
{_.map(data, (item, i) => <MyComponent key={i} text={item.text})}
</ul>
)
}
让我知道我是否可以更清楚一些事情。