调用 repl.start 时未正确分配 Eval

问题描述 投票:0回答:0

使用以下代码:

const repl = require('repl')

function simpleEval(cmd, context, filename, callback) {
    console.log('got eval')
}

function handleOutput(output) {
    console.log('got output ' + output)
    return ''
}

const server = repl.start({
    eval: simpleEval,
    prompt: 'Enter Userid: >> ',
    terminal: true,
    ignoreUndefined: true,
    writer: handleOutput
})

当我在创建服务器后在调试器中暂停时,它显示:

为什么不将 server.eval 设置为 simpleEval 函数?

node.js read-eval-print-loop
© www.soinside.com 2019 - 2024. All rights reserved.