reloadNuxtApp

reloadNuxtApp 将执行页面的硬重新加载。
reloadNuxtApp 将对你的应用执行硬重新加载,从服务器重新请求页面及其依赖。

默认情况下,它还会保存应用当前的 state(即你可以使用 useState 访问的任何状态)。

¥By default, it will also save the current state of your app (that is, any state you could access with useState).

:

Read more in Docs > Guide > Going Further > Experimental Features#restorestate.

你可以通过在 nuxt.config 文件中启用 experimental.restoreState 选项来实验性地恢复此状态。

¥You can enable experimental restoration of this state by enabling the experimental.restoreState option in your nuxt.config file.

::

类型

¥Type

reloadNuxtApp(options?: ReloadNuxtAppOptions)

interface ReloadNuxtAppOptions {
  ttl?: number
  force?: boolean
  path?: string
  persistState?: boolean
}

options(可选)

¥options (optional)

类型:ReloadNuxtAppOptions

¥Type: ReloadNuxtAppOptions

接受以下属性的对象:

¥An object accepting the following properties:

  • path(可选)
    类型:string
    默认:window.location.pathname
    重新加载的路径(默认为当前路径)。如果这与当前窗口位置不同,它将触发导航并在浏览器历史记录中添加一个条目。
  • ttl(可选)
    类型:number
    默认:10000
    忽略未来重新加载请求的毫秒数。如果在此时间段内再次调用,reloadNuxtApp 将不会重新加载你的应用,以避免重新加载循环。
  • force(可选)
    类型:boolean
    默认:false
    此选项允许完全绕过重新加载循环保护,即使在先前指定的 TTL 内发生过重新加载,也会强制重新加载。
  • persistState(可选)
    类型:boolean
    默认:false
    是否将当前 Nuxt 状态转储到 sessionStorage(作为 nuxt:reload:state)。默认情况下,这不会影响重新加载,除非也设置了 experimental.restoreState,或者你自行处理恢复状态。