From 6fc787dfbd55fc0b9aa4b84b0781f9f2825ffd1f Mon Sep 17 00:00:00 2001 From: YM <479443481@qq.com> Date: 星期三, 15 五月 2024 14:04:41 +0800 Subject: [PATCH] 1 --- src/main.js | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main.js b/src/main.js index 1042e4d..0079324 100644 --- a/src/main.js +++ b/src/main.js @@ -30,7 +30,9 @@ let instance = null; function render(props = {}) { - const { container } = props; + const { container, onGlobalStateChange, setGlobalState } = props; + Vue.prototype.onGlobalStateChange = onGlobalStateChange; + Vue.prototype.setGlobalState = setGlobalState; instance = new Vue({ // router, store, @@ -46,15 +48,18 @@ // qiankun export async function bootstrap() {} export async function mount(props) { - console.log(props, "瀛愬眰鑾峰彇鐨刾rops"); + console.log(props, "瀛愬眰propspropspropsprops"); props.onGlobalStateChange((state, prev) => { // state: 鍙樻洿鍚庣殑鐘舵��; prev 鍙樻洿鍓嶇殑鐘舵�� - console.log("瀛愬眰change锛�",state, prev); - if (state.bb) state.bb(123) + console.log("瀛愬眰鍙樺寲锛�", state, prev); + // 鐘舵�佸彉鍖栧悓姝uex锛岀敤浜庡悇椤甸潰璋冪敤 + store.commit("setQiankun", state); }); props.setGlobalState({ - aa: 2 + state: 3, // 搴旂敤鎸傝浇瀹屾垚锛屽悓鏃剁敤浜庤Е鍙戜竴娆tateChange灏唖tate鎸傝浇鍦╲uex褰撲腑 + bookName: config.activeBook.bookName, + bookId: config.activeBook.bookId }); render(props); @@ -65,7 +70,7 @@ instance = null; } -// new Vue({ -// store, -// render: (h) => h(App) -// }).$mount("#app"); +// 澧炲姞 update 閽╁瓙浠ヤ究涓诲簲鐢ㄦ墜鍔ㄦ洿鏂板井搴旂敤 +// export async function update(props) { +// render(props); +// } -- Gitblit v1.9.1