Nodejs 脚本通过控制台在服务器上启动。
nodejs script.js
是否可以以某种方式直接从控制台执行该脚本的功能之一?
例如:
//script.js
let timer = null;
function stopLoop() {
self.clearInterval(timer);
timer = null;
}
timer = self.setInterval(() => {
console.log('loop');
}, 1000);
<div>Без него не дает вставить фрагмент</div>
我运行脚本:
nodejs script.js
我随时调用它的函数:
nodejs script.js:stopLoop
这个可以实现吗?