本文整理匯總了TypeScript中nprogress.done函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript done函數的具體用法?TypeScript done怎麽用?TypeScript done使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了done函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: next
router.beforeEach((to: Route, from: Route, next: any) => {
NProgress.start();
if (getToken()) {
if (to.path === '/login') {
next({ path: '/' });
NProgress.done(); // If current page is dashboard will not trigger afterEach hook, so manually handle it
} else {
next()
// if (UserModule.roles.length === 0) {
// UserModule.GetInfo().then(() => {
// next();
// }).catch((err) => {
// UserModule.FedLogOut().then(() => {
// Message.error(err || 'Verification failed, please login again');
// next({ path: '/' });
// });
// });
// } else {
// next();
// }
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
next();
} else {
next(`/login?redirect=${to.path}`); // 否則全部重定向到登錄頁
NProgress.done();
}
}
// next();
});
示例2: createAction
export const getUsers = createAction('GET_USERS', async () => {
try {
NProgress.start();
return await client.users.getUsers();
} finally {
NProgress.done();
}
});
示例3: createAction
export const fetch = createAction('FETCH', async (url: string) => {
try {
NProgress.start();
const response = await request.get(url);
return response.text;
} finally {
NProgress.done();
}
}, (url: string) => ({ url }));
示例4: Message
}, (error: any) => {
NProgress.done()
let resData = error.response.data || {}
Message({
message: resData.message || error.message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
})
示例5:
service.interceptors.response.use((response) => {
NProgress.done()
const res = response.data;
if (res.code !== 20000) {
// return Promise.reject('error');
} else {
return response.data;
}
}, (error: any) => {
示例6: setTimeout
setTimeout(()=> NProgress.done(), 1000);
示例8:
Router.onRouteChangeComplete = () => progress.done();
示例9:
router.afterEach(() => {
console.log(121);
NProgress.done(); // 結束Progress
});