跳至内容

框架

基本框架

通过期望任何跟随的链接或表单提交返回包含匹配帧标记的响应,将所有导航限制在帧内

<turbo-frame id="messages">
<a href="/messages/expanded">
Show all expanded messages in this frame.
</a>

<form action="/messages">
Show response from this form within this frame.
</form>
</turbo-frame>

急切加载的帧

与基本帧类似,但内容首先从远程src加载。

<turbo-frame id="messages" src="/messages">
Content will be replaced when /messages has been loaded.
</turbo-frame>

延迟加载的帧

类似于急切加载的帧,但内容在帧可见之前不会从src加载。

<turbo-frame id="messages" src="/messages" loading="lazy">
Content will be replaced when the frame becomes visible and /messages has been loaded.
</turbo-frame>

默认情况下将整个页面作为目标的帧

<turbo-frame id="messages" target="_top">
<a href="/messages/1">
Following link will replace the whole page, not this frame.
</a>

<a href="/messages/1" data-turbo-frame="_self">
Following link will replace just this frame.
</a>

<form action="/messages">
Submitting form will replace the whole page, not this frame.
</form>
</turbo-frame>

覆盖导航目标的帧

<turbo-frame id="messages">
<a href="/messages/1">
Following link will replace this frame.
</a>

<a href="/messages/1" data-turbo-frame="_top">
Following link will replace the whole page, not this frame.
</a>

<form action="/messages" data-turbo-frame="navigation">
Submitting form will replace the navigation frame.
</form>
</turbo-frame>

将导航提升为访问的帧

<turbo-frame id="messages" data-turbo-action="advance">
<a href="/messages?page=2">Advance history to next page</a>
<a href="/messages?page=2" data-turbo-action="replace">Replace history with next page</a>
</turbo-frame>

在页面刷新期间将使用变形重新加载的帧

<turbo-frame id="my-frame" refresh="morph">
...
</turbo-frame>

属性、特性和函数

<turbo-frame>元素是一个 自定义元素,具有自己的一组 HTML 属性和 JavaScript 特性。

HTML 属性

属性

所有 <turbo-frame> 元素都可以通过 FrameElement 类的实例在 JavaScript 环境中进行控制。

函数

下一步:流