javascript - Javascript - 得到一个未捕获的类型错误
问题描述
创建井字游戏,但由于某种原因,在执行observer.observe 时出现未捕获的类型错误。
这是发生错误的行:
board.positions.forEach((el) => observer.observe(el,config));
这是它发生的功能:
function TicTacToeGame() {
const board = new Board();
const humanPlayer = new HumanPlayer(board);
const computerPlayer = new ComputerPlayer(board);
let turn = 0;
this.start = function () {
const config = {childlist: true};
const observer = new MutationObserver(()=> takeTurn());
board.positions.forEach((el) => observer.observe(el,config));
takeTurn();
}
这个错误试图说什么以及解决它的最佳方法是什么。
编辑:这是我得到的错误:
Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': The options object must set at least one of 'attributes', 'characterData', or 'childList' to true.
解决方案
推荐阅读
- reactjs - ReactJS/Next.js:CRA 代理不适用于 Next.js(尝试将 API 请求路由到 Express 服务器)
- rust - 使用 Real-Time For the Masses 时对 main 的未定义引用
- javascript - 桌子上光滑的旋转木马
- c# - 如何在 Blazor 中实现拖放?
- amazon-web-services - AWS Cognito 中的“访问令牌不包含 openid 范围”
- jquery - 使用 jQuery 设置元素高度不起作用
- python - 获取邮件 IMAPCLIENT 的内容
- android - android studio的设备文件资源管理器中缺少数据库文件夹
- nginx - 重新加载 nginx 配置飞行中的 http 1.1 请求在完成后关闭,没有 Connection:close
- java - 杰克逊无法将 json 转换为地图列表