Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在我的 span 标签中包含一个 erb 标签,如下所示:
<span style="width:' +<% @completion %>''%'"></span>
但它不起作用。有谁知道该怎么做?
您需要输出 的返回值@completion,在 erb 中您可以通过以下方式实现:
@completion
# with an equal sign: <span><%= "Hello!" %></span> # but the following will not output "hello" <span><% "Hello!" %></span> #^ no equal sign -> not displayed
在你的情况下:
<span style="width: <%= @completion %>%;"></span>
希望有帮助!