dfs(x, y,no,book) {
let next = [[-1, 0], [1, 0], [0, -1], [0, 1]];
let tx, ty;
for (let i = 0; i < 4; i++) {
tx = x + next[i][0];
ty = y + next[i][1];
if (tx < 1 || ty < 1 || tx > 5 || ty > 5)
continue;
if (book[tx][ty] == 0 && XA[tx][ty]._name == no._name) {
book[tx][ty] = -1; //标记走过
this.dfs(tx, ty,no,book); //递归
book[tx][ty] = 0; //取消标记
}
}
}
//该函数为回调函数
des(event: TweenAction) {
let book = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]];
book[Math.floor((event._siblingIndex - 1) / 5)][((event._siblingIndex - 1) % 5)] = -1;
this.dfs(Math.floor((event._siblingIndex - 1) / 5), ((event._siblingIndex - 1) % 5), event,book);
console.log(book);
}
在start()函数中调用了该回调函数des,回调函数des中调用了dfs方法,但是执行后报错,报错为Cannot read properties of null (reading 'dfs'),如何解决