From 62e971bb894c05f5b01b7dd01cbe8d9c56da461c Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期六, 11 五月 2024 18:23:30 +0800 Subject: [PATCH] 父子通信 --- src/main.js | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main.js b/src/main.js index 4c7b792..ee43d47 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,7 @@ import Vue from "vue"; import App from "./App.vue"; import less from "less"; -import "./assets/style/base.css"; -import "./assets/style/main.css"; +import "./books/childHealth/assets/main.less"; import ElementUI from "element-ui"; import "element-ui/lib/theme-chalk/index.css"; import store from "./store"; @@ -30,13 +29,14 @@ let instance = null; -function render(props = {}) { - const { container } = props; +function render(actions = {}) { + // const { container } = props; instance = new Vue({ // router, + actions, store, render: (h) => h(App) - }).$mount(container ? container.querySelector("#app") : "#app"); + }).$mount(actions.container ? actions.container.querySelector("#app") : "#app"); } // 鐙珛杩愯鏃� @@ -47,6 +47,17 @@ // qiankun export async function bootstrap() {} export async function mount(props) { + console.log(props, "瀛愬眰鑾峰彇鐨刾rops"); + props.onGlobalStateChange((state, prev) => { + // state: 鍙樻洿鍚庣殑鐘舵��; prev 鍙樻洿鍓嶇殑鐘舵�� + console.log("瀛愬眰change锛�",state, prev); + if (state.bb) state.bb(123) + }); + + props.setGlobalState({ + aa: 2 + }); + render(props); } export async function unmount() { @@ -55,7 +66,7 @@ instance = null; } -new Vue({ - store, - render: (h) => h(App) -}).$mount("#app"); +// new Vue({ +// store, +// render: (h) => h(App) +// }).$mount("#app"); -- Gitblit v1.9.1