闫增涛
2024-05-11 62e971bb894c05f5b01b7dd01cbe8d9c56da461c
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, "子层获取的props");
  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");