From d96e8edbe496bde2875c75864a39324b1d8e5b70 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Thu, 24 Mar 2022 12:02:14 +0800
Subject: [PATCH] 优化跨页面数据传递

---
 bases/Pilot.js |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/bases/Pilot.js b/bases/Pilot.js
index 295eb12..6fa3641 100644
--- a/bases/Pilot.js
+++ b/bases/Pilot.js
@@ -92,6 +92,8 @@
     // 创建页面通讯器
     static createPoster($vm) {
         return (pageType, action, data) => {
+            // 解除引用关系
+            const nextData = JSON.parse(JSON.stringify(data));
             // 下一页
             if (pageType === 'nextPage') {
                 // 持续 3 秒,检测下一页是否存在
@@ -105,7 +107,7 @@
                     const nextPage = currentPages[pageIndex + 1];
                     if (nextPage) {
                         clearInterval(timer);
-                        nextPage.$component.$onMessage(action, data);
+                        nextPage.$component.$onMessage(action, nextData);
                     }
                 }, 50);
             } else if (pageType === 'prevPage') {
@@ -113,12 +115,12 @@
                 const pageIndex = currentPages.findIndex(page => page.$component === $vm);
                 const prevPage = currentPages[pageIndex - 1];
                 if (prevPage) {
-                    prevPage.$component.$onMessage(action, data);
+                    prevPage.$component.$onMessage(action, nextData);
                 }
             } else if (pageType === 'rootPage') {
                 const currentPages = getCurrentPages();
                 const rootPage = currentPages[0];
-                rootPage.$component.$onMessage(action, data);
+                rootPage.$component.$onMessage(action, nextData);
             }
         };
     }

--
Gitblit v1.9.1