From 9fad1ec855e1a31c9b6087cfc6c7bdbd3fca5de6 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Mon, 1 Jun 2020 14:51:33 +0800 Subject: [PATCH] u --- index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index e2d6efb..b4f328d 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,9 @@ module.exports = { - clog(message){ - console.log('【【【【【【【【【【', getApp().$options.router.currentRoute.path, message, '】】】】】】】】】】】') + clog(...message){ + console.log('【【【【【【【【【【', + getCurrentPages().length>0 ? getCurrentPages().pop().route : 'pages/Welcome', // 在首页时,getApp() 或 getCurrentPages() 有可能获取不到。 + ...message, + '】】】】】】】】】】】') }, async request(obj){ @@ -18,9 +21,9 @@ module.exports = { } } - console.log('👇 👇 👇 👇 👇 👇 👇 👇 < Request >', obj, '👆 👆 👆 👆 👆 👆 👆 👆 < /Request >') + console.log('👇 👇 👇 👇 < Request > 👇 👇 👇 👇 ', obj, '👆 👆 👆 👆 < /Request > 👆 👆 👆 👆') let [error, response] = await uni.request(obj) - console.log('⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ < Response >', response, '⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ < /Response >') + console.log('⬇️ ⬇️ ⬇️ ⬇️ < Response > ⬇️ ⬇️ ⬇️ ⬇️ ', response, '⬆️ ⬆️ ⬆️ ⬆️ < /Response > ⬆️ ⬆️ ⬆️ ⬆️') return [error, response] }, @@ -74,8 +77,7 @@ module.exports = { }, showToast({type, icon, image, title, duration}){ - let pageStack = getCurrentPages() - let pageNow = pageStack[pageStack.length-1] + let pageNow = getCurrentPages().pop() if (pageNow.$refs && pageNow.$refs.toast) { pageNow.$refs.toast.open({type, content:title, duration}) }else {