0

如何解决参数类型 (key:string) => Observable | 的问题 有效载荷类型 | 不能分配给“(值:字符串,索引:数字)=> ObersvableInput”类型的参数

return action$.pipe(
    filter(a => a.type === 'ACTION'),
    mergeMap(action => {
        hideLoadingMask();
        return askForMessageDialog({
            title: 'test',
            type: 'question',
            text: getLocalized('test'),
            buttons: [
            { key: 'cancel', caption: 'cancel'},
            { key: 'notSave', caption: 'notSave' },
            { key: 'save', caption: 'save' }],
            primaryButtonKey: cancel
        }).pipe(
            mergeMap((key) => {
                switch (key) {
                    case notSave: {
                        return refresh();
                    }
                    case save: {
                        return saveChanges();
                    }
                    default: 
                        return empty();
                }
            })
        );
        
    })
);
4

1 回答 1

0

我不得不将代码更新为:

switch (key) {
                    case notSave: {
                        return of(refresh());
                    }
                    case save: {
                        return of(saveChanges());
                    }
                    default: 
                        return empty();
                }
于 2021-10-20T09:24:00.463 回答