From 2923c8c9d6d41cd51921acc1db6f1c58f8cfa697 Mon Sep 17 00:00:00 2001 From: RickCole21 Date: Fri, 28 Feb 2020 10:36:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?service=E5=91=BD=E4=B8=AD=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderers/Form/Service.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/renderers/Form/Service.tsx b/src/renderers/Form/Service.tsx index 30b882c0..2c9cbcc4 100644 --- a/src/renderers/Form/Service.tsx +++ b/src/renderers/Form/Service.tsx @@ -8,7 +8,7 @@ import {observer} from 'mobx-react'; import {ServiceStore, IServiceStore} from '../../store/service'; @Renderer({ - test: /(^|\/)form(?:\/.+)?\/control\/(?:\d+\/)?service$/, + test: /(^|\/)form\/(.*)\/service$/, weight: -100, storeType: ServiceStore.name, storeExtendsData: false, @@ -25,7 +25,9 @@ export class ServiceRenderer extends BasicService { componentDidMount() { const {formInited, addHook} = this.props; - if (formInited) { + // form层级下的所有service应该都会走这里 + // 但是传入props有可能是undefined,所以做个处理 + if (formInited !== false) { super.componentDidMount(); } else { addHook && addHook(this.initFetch, 'init'); From b1eafeab05a5c84e9f1444f511476fef80d8526c Mon Sep 17 00:00:00 2001 From: RickCole21 Date: Fri, 28 Feb 2020 10:42:49 +0800 Subject: [PATCH 2/2] fix --- src/renderers/Form/Service.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/Form/Service.tsx b/src/renderers/Form/Service.tsx index 2c9cbcc4..d20d9c01 100644 --- a/src/renderers/Form/Service.tsx +++ b/src/renderers/Form/Service.tsx @@ -36,7 +36,7 @@ export class ServiceRenderer extends BasicService { componentDidUpdate(prevProps: ServiceProps) { const {formInited} = this.props; - if (formInited) { + if (formInited !== false) { super.componentDidUpdate(prevProps); } }