我在Ubuntu 20.04上使用VSCode,无法逐步执行递归函数。
该应用程序是NodeJS,没有浏览器。
通过npm start
运行
"start": "nodemon --exec babel-node src/try2.js"
逐步执行此非递归功能会很好。
class Person {
constructor(name) {
this._name = name // {1}
}
get name() {
// {2}
return this._name
}
set name(value) {
// {3}
this._name = value
}
}
let lotrChar = new Person('Frodo')
lotrChar.name = 'Gandalf' // {5}
lotrChar._name = 'Sam' // {6}
console.log(lotrChar._name)
但是,使用此功能,在调试时在第一条if
和第二条function factorial(n) {
if (n < 0) {
return undefined;
}
if (n === 1 || n === 0) {
return 1;
}
return n * factorial(n - 1);
}
const a = factorial(5)
console.log('a', a)
语句上都有一个断点
{
"version": "0.2.0",
"configurations": [
{
"sourceMaps": true,
"smartStep": true,
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**",
"node_modules"
],
"program": "${workspaceFolder}/src/try2.js",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": [
"--nolazy"
]
}
]
}
launch.json
this._router.navigate(['/index']);
document.getElementById("loginmodalhref").click();
我做了一个简短的视频来说明问题。