首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >国际象棋能用棋盘@8或更高吗?

国际象棋能用棋盘@8或更高吗?
EN

Stack Overflow用户
提问于 2022-04-26 02:12:44
回答 1查看 84关注 0票数 1

我创建了一个react应用程序,与chessground@7.16.13一起工作。

现在我正在尝试将chessground升级到8.2.1版本,但是有8个错误如下:

代码语言:javascript
运行
复制
ERROR in ./node_modules/react-chessground/node_modules/chessground/chessground.js 1:0-30
Module not found: Error: Can't resolve './api' in 'C:\User\file\node_modules\react-chessground\node_modules\chessground'
Did you mean 'api.js'?
BREAKING CHANGE: The request './api' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

对于'./config‘、'./state’、‘./包’、'./events‘、’./呈现‘、'./svg’、'./util‘也是如此。

这是我的密码:

代码语言:javascript
运行
复制
import { useState } from "react";
import Chessground from "react-chessground";
import "./chess.css";
import "./styles.css";
import "./theme.css";
import toDests from "./to-dests";
import { Chess } from "chess.js";

export default function Board() {
    const [fen, setFen] = useState(
        "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
    );

    const chess = new Chess(fen);
    const turnColor = chess.turn() === "w" ? "white" : "black";
  
    const handleMove = ( from, to ) => {
      chess.move({ from, to, promotion: "q" });
      setFen(chess.fen());
    };

    return (
        <div className="justChessBoard">
          <div>
            <Chessground
              fen={fen}
              turnColor={turnColor}
              onMove={handleMove}
              movable={toDests(chess)}
            />
          </div>
        </div>
    );
}

我是做错了什么还是不能一起工作?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72007642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档