Closed ywjjjjjj closed 4 years ago
伪代码
/// 通用状态 class CommonState{ int id; CommonProps commonProps; AProps aProps; bProps bProps; } /// 状态转换 class ACon<CommonState> extends ConnOp<CommonState, CommonState> { @override CommonState get(CommonState state) { CommonState newState = state.clone(); /// ComponentChildA 需要使用的数据从 comProps 中转换 newState.aProps = ...; return newState; } @override void set(CommonState state, CommonState subState) { /// 一个 subState 发生了变动,会触发所有的 set 方法,所以加一个id 判断 if (state.id==subState.id) { state = subState.clone(); } } } /// 通用的列表父组件 class ComponentParentA<CommonState>{} /// 根据父组件 commonProps 的一些数据,比如type,来区分引入哪个子组件 class ComponentChildA<CommonState>{} class ComponentChildB<CommonState>{}
换了种思路解决了,打扰了
伪代码