gpt4 book ai didi

vue.js - 如何禁用nuxt默认错误重定向

转载 作者:行者123 更新时间:2023-12-03 09:27:58 25 4
gpt4 key购买 nike

使用Vuetify设置一个nuxt项目。其中一页使用client-only(no-ssr)组件。在开发过程中,如果该组件发生错误,我将被重定向到默认错误页面,这使我无法使用Vue devtools检查变量和组件。

我觉得这应该非常简单,但是我找不到禁用这种自动重定向行为的方法。所以我想我的问题是如何禁用nuxt默认错误重定向?

最佳答案

您不能通过nuxt配置禁用<nuxt-error>渲染。
另一种方法是修改nuxt渲染,如下所示:
1/打开文件./node_modules/@nuxt/vue-app/template/components/nuxt.js2/转到render(h)方法
3/删除错误条件以始终显示组件:

  render (h) {

// HACK TO SKIP ERROR
this.nuxt.err = false

// if there is no error
if (!this.nuxt.err) {
// Directly return nuxt child
return h('NuxtChild', {
key: this.routerViewKey,
props: this.$props
})
}

// ...
}

nb:每次npm或yarn安装后,上述文件中的hack将被覆盖。

关于vue.js - 如何禁用nuxt默认错误重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59292573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com