【问题标题】:Adding styling to rails react component wrapping div向rails添加样式反应组件包装div
【发布时间】:2015-06-26 02:25:27
【问题描述】:

我在我的 Rails 项目中使用react_component。这会为 react.js 组件插入一个包装 div,例如

<div data-react-class="ButtonSwitchToTab" data-react-props="{...}">
  <a href="#" class="btn btn-primary btn-lg" ... data-reactid=".2">
    Add / Invite People
  </a>
</div>

我真正需要的是在这个包装 div 中插入样式信息,以便组件正确对齐,如下所示:

<div data-react-class="ButtonSwitchToTab" data-react-props="{...}"
 style="display:inline-block">  <<<<<------
  <a href="#" class="btn btn-primary btn-lg" ... data-reactid=".2">
    Add / Invite People
  </a>
</div>

这样做的适当方法是什么?

【问题讨论】:

    标签: ruby-on-rails-4 reactjs react-rails


    【解决方案1】:

    啊,深入了解react_rails doco (Helper's signature),发现我可以添加 pass-through html_options

    所以:

    <%= react_component('ButtonSwitchToTab', {prop: .., prop: ..}, 
                        {:style => "display:inline-block"}) %>
    

    【讨论】:

      猜你喜欢
      • 2020-04-28
      • 2017-05-21
      • 2020-05-02
      • 2018-09-24
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 1970-01-01
      相关资源
      最近更新 更多