为什么 Rails Turbo 的turbo_frame_tags内容没有出现在网页中?



我遵循Hotwire的官方指导(https://hotwired.dev/#screencast),试图测试Rails Turbo的排序功能。然而,我发现turbo_frame_tag包装的一些内容不会显示在页面中

这是在应用程序\视图\房间\显示

<%= turbo_frame_tag "new_messages" , src: new_room_message_path(@room), target: "_top" %>

是否有教学视频中未提及的必要设置?

使用具有src属性的turbo帧将用您指定的URL中的内容替换turbo帧的内部html,并用匹配的id替换turbo帧。因此,您可以使用它来显示将从url加载的内容的加载UI。

<turbo-frame id="long-calculation" src="/long-calculation">
<i class="fa fa-spinner fa-spin"> </i> # Will get replaced with the results from the `/long-calculation` page
</turbo-frame>

最新更新