Commit b796ce39 by zhaochengxiang

乾坤传参问题

parent 66dc4260
...@@ -31,20 +31,23 @@ const AssetTree = loadable(()=> import('./view/Manage/AssetManage/Component/Asse ...@@ -31,20 +31,23 @@ const AssetTree = loadable(()=> import('./view/Manage/AssetManage/Component/Asse
export class App extends React.Component { export class App extends React.Component {
constructor() { constructor() {
super(); super();
this.$$hostParams = null;
this.state = { this.state = {
hostParams: this.params hostParams: null
}; };
} }
componentDidMount() { componentDidMount() {
this.setState({ hostParams: this.props?.data });
this.$$hostParams = $hostParams.subscribe(() => { this.$$hostParams = $hostParams.subscribe(() => {
if ($hostParams.getValue()) {
this.setState({ hostParams: $hostParams.getValue() }); this.setState({ hostParams: $hostParams.getValue() });
}
}) })
} }
componentWillUnmount() { componentWillUnmount() {
this.$$hostParams?.unsubscribe() this.$$hostParams?.unsubscribe();
} }
render() { render() {
......
...@@ -14,6 +14,7 @@ import { $hostParams } from "./util"; ...@@ -14,6 +14,7 @@ import { $hostParams } from "./util";
function render(props) { function render(props) {
const { container, ...restProps } = props; const { container, ...restProps } = props;
ReactDOM.render( ReactDOM.render(
//解决主次应用样式冲突 //解决主次应用样式冲突
//https://qiankun.umijs.org/faq#how-to-guarantee-the-main-app-stylesheet-isolated-with-sub-apps //https://qiankun.umijs.org/faq#how-to-guarantee-the-main-app-stylesheet-isolated-with-sub-apps
...@@ -55,5 +56,5 @@ export async function unmount(props) { ...@@ -55,5 +56,5 @@ export async function unmount(props) {
} }
export async function update(props) { export async function update(props) {
$hostParams.next(props); $hostParams.next(props?.data);
} }
\ No newline at end of file
...@@ -17,7 +17,7 @@ export const inputWidth = isSzseEnv?360:240; ...@@ -17,7 +17,7 @@ export const inputWidth = isSzseEnv?360:240;
export const ContextPath = '/data-govern'; export const ContextPath = '/data-govern';
export const $hostParams = new BehaviorSubject({}); export const $hostParams = new BehaviorSubject(null);
const routeMap = {}; const routeMap = {};
export const ConvertToRouteMap = function (routes, pPath, pRoute) { export const ConvertToRouteMap = function (routes, pPath, pRoute) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment