我使用Rails很新,但有经验作出反应。我想和ERB文件某物管理,我可以做会那样:参数化的嵌套ERB组件
class MyElement extends Component {
render() {
return <div>
some text
{this.props.myFirstParam + this.props.mySecondParam}
some another text
</div>
}
}
class MyBody extends Component {
render() {
return <body>
<MyElement myFirstParam={1} mySecondParam={2} />
<MyElement myFirstParam={3} mySecondParam={5} />
<MyElement myFirstParam={7} mySecondParam={3} />
</body>
}
}
我当然知道,在服务器端的Rails程序的文件,但我想只是为了显示组件的想法筑巢。我想避免方法中的命令式字符串连接。有没有一些好方法可以做到这一点?
你看过吗? https://github.com/reactjs/react-rails – Swards
我想我被误解了。我不想使用React。我只想用Rails做同样的事情,我可以轻松地用React做,但没有它。 –