Replies: 1 comment
-
这个问题我目前想不出解决办法,使用 你可以考虑一下使用其他方式,例如 window.onerror,不过我也不是特别确定。 我之前简单调研过 react 的生态,并没有类似的机制,看起来也没有太大的影响。 看起来错误处理终究是个比较复杂的问题。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
在一般的企业应用中,页面仅负责处理业务逻辑,由errorHandler来统一处理异常,是比较适合的。async/await语法更简洁,但NButton的click事件不支持async/await语法(因其内部实现无论事件绑定的是同步还是异步函数,均使用了同步的调用方式,因此在app.config.errorHandler中不能捕获到异常)。
例如:
<n-button type="primary" @click="login">Login
async function login(): Promise {
try {
await loginForm.value.validate()
} catch (error) {
return
}
await authService.login(user.value)
await router.push('/dashboard')
}
一个月前已提出这个问题,希望尽快解决。
Beta Was this translation helpful? Give feedback.
All reactions