组件 Html 是这样的
<input type="text" placeholder="input first" id="input1">
<input type="text" id="input2" placeholder="input second">
<span></span>
导入所需功能
import { fromEvent } from 'rxjs'
import { map, mergeMap } from 'rxjs/operators'
var span = document.querySelector('span');
var input1 = document.querySelector('#input1');
var input2 = document.querySelector('#input2');
var obs1 = fromEvent(input1, 'input');
var obs2 = fromEvent(input2, 'input');
var obs1 = fromEvent(input1, 'input');
var obs2 = fromEvent(input2, 'input');
obs1.pipe(mergeMap(event1 => obs2.pipe(
map(event2 => (<HTMLInputElement>event1.target).value
+ " "
+ (<HTMLInputElement>event2.target).value))))
.subscribe((result) => {
span.textContent=result;
})