嘗試將「s」字符串添加到在帶風格的組件中傳遞的道具時遇到問題。另外,我不完全確定我是否可以在樣式化組件中使用prop.x
。這就是我的意思是:帶風格的組件中的字符串的Concat支持值
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>
)
}
讓我知道,如果我能上的東西更清楚。
我想,第一,由於某種原因,沒有工作......但現在它呢!穆斯塔有一個更大的問題或類型o ...感謝Ekkasit! – archae0pteryx