'line' 事件
每当 input
流接收到行尾输入(\n
、\r
或 \r\n
)时,则会触发 'line'
事件。
使用包含单行接收输入的字符串调用监听器函数。
rl.on('line', (input) => {
console.log(`Received: ${input}`);
});
The 'line'
event is emitted whenever the input
stream receives an
end-of-line input (\n
, \r
, or \r\n
). This usually occurs when the user
presses the <Enter>
, or <Return>
keys.
The listener function is called with a string containing the single line of received input.
rl.on('line', (input) => {
console.log(`Received: ${input}`);
});