返回上一页

查看源码

属性参考

注册名 data-controller="history-back"
Targets
Values
Outlets

有历史记录时 history.back(),没有时按 url value 用 Turbo.replace 回首页;位于历史栈底时自动隐藏返回图标,并在 connect 后移除自身 controller 避免 morph 重复绑定。

<button
  id="history-button" 
  data-controller="history-back"
  data-history-back-url-value="/"
  class="is-link"
>返回</button>