在 Rxjs 中使用 mergeMap 时未定义的输出

undefined output while using mergeMap in Rxjs

理论上,我知道 mergeMap 是什么以及它是如何工作的,但是当我尝试理解使用 实用方法我感到困惑,这是我到目前为止所做的

const input1$= of("value 1","value 2","value 3");
const input2$= of(1,2,3,4);
const obs=input1$.pipe(
            mergeMap(data1=>{
              return input2$
              .pipe(map(ch=>{ch+' '+data1}))})
        )   

不幸的是,当我尝试合并它们时,我得到了未定义的信息,如果您能帮助我理解它是如何工作的,我们将不胜感激。

您没有在第二个管道中返回任何东西

试试这个

const obs=input1$.pipe(
            mergeMap(data1=>{
              return input2$
              .pipe(map(ch=>{
              return ch+' '+data1
              }))})
        )