返回的嵌套divs
我正在尝试返回与此类似的结构
<div style="someCSS">
<div style="someOtherCSS"></div>
<div style="someOtherCSS"></div>
</div>
<div style="someCSS">
<div style="someOtherCSS"></div>
<div style="someOtherCSS"></div>
<div style="someOtherCSS"></div>
</div>
,但我正在围绕这个想法工作,但这不是很正确,我不知道该怎么办。
const nestedDivs = () => {
for (let i = 0; i <= x; i++) {
for (let j = 0; j <= y; j++) {
let someOtherCSS{
borderColor: '#fff',
borderSize: '1px',
borderStyle: 'solid',
background: '#ffcc00',
};
fooStyle.push(<div style={someOtherCSS}></div>);
}
let someCSS{
borderColor: '#fff',
borderSize: '1px',
borderStyle: 'solid',
background: '#ff0000',
};
fooStyle.unshift(<div style={someCSS}></div>);
}
return fooStyle;
}
I am trying to return a structure similar to this
<div style="someCSS">
<div style="someOtherCSS"></div>
<div style="someOtherCSS"></div>
</div>
<div style="someCSS">
<div style="someOtherCSS"></div>
<div style="someOtherCSS"></div>
<div style="someOtherCSS"></div>
</div>
I am working around this idea, but it's not quite right, and I don't know what to do.
const nestedDivs = () => {
for (let i = 0; i <= x; i++) {
for (let j = 0; j <= y; j++) {
let someOtherCSS{
borderColor: '#fff',
borderSize: '1px',
borderStyle: 'solid',
background: '#ffcc00',
};
fooStyle.push(<div style={someOtherCSS}></div>);
}
let someCSS{
borderColor: '#fff',
borderSize: '1px',
borderStyle: 'solid',
background: '#ff0000',
};
fooStyle.unshift(<div style={someCSS}></div>);
}
return fooStyle;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的代码正常执行,并且只是在附加某些hothercss 中遇到问题,则将其分为 somecss ,那么您可以尝试一下,
希望这对您有帮助!快乐的编码...
If your code is executing properly and just have issue with appending someOtherCSS divs into someCSS, then you can try this,
Hope this will helpful to you! Happy coding...
您还可以尝试下面的尝试,它使用文本进行contet html,然后使用dangernlysetinnerhtml进行html。
You can give a below try also, it uses text for concat the html and then dangerouslySetInnerHTML to string HTML.