feat: 新增初始化函数,全局异步错误捕获功能
This commit is contained in:
parent
3a256cbd88
commit
68b8809a1e
@ -3,7 +3,7 @@ import App from './App.vue'
|
||||
import router, { setupRouter } from '@/router'
|
||||
import i18n from '@/i18n/index'
|
||||
import { setupStore } from '@/store'
|
||||
import { setupNaive, setupDirectives, setupCustomComponents } from '@/plugins'
|
||||
import { setupNaive, setupDirectives, setupCustomComponents, initFunction } from '@/plugins'
|
||||
import { GoAppProvider } from '@/components/GoAppProvider/index'
|
||||
import { setHtmlTheme } from '@/utils'
|
||||
|
||||
@ -53,4 +53,6 @@ async function appInit() {
|
||||
window['$vue'] = app
|
||||
}
|
||||
|
||||
void appInit()
|
||||
await appInit()
|
||||
|
||||
await initFunction()
|
||||
|
@ -2,3 +2,4 @@ export { setupNaive } from '@/plugins/naive'
|
||||
export { setupDirectives } from '@/plugins/directives'
|
||||
export { setupCustomComponents } from '@/plugins/customComponents'
|
||||
export { icon } from '@/plugins/icon'
|
||||
export { initFunction } from '@/plugins/initFunction'
|
||||
|
9
src/plugins/initFunction.ts
Normal file
9
src/plugins/initFunction.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* * 页面初始化就执行的函数
|
||||
*/
|
||||
export const initFunction = async () => {
|
||||
// 捕获全局错误
|
||||
window.addEventListener("unhandledrejection", event => {
|
||||
console.warn(`UNHANDLED PROMISE REJECTION: ${event.reason}`);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user