我有一个npm库,我将其导入到我的应用程序中,如下所示:
import Chess from 'chess.js';
let chess = new Chess();下面的链接中显示了一个使用chess.moves()的方法
https://github.com/jhlywa/chess.js/blob/master/README.md
以上两行代码在我的文件App.js中。我有一个utilities.js文件,我想在其中放置一个函数,这个函数是从我的函数在App.js中调用的。但是,我希望能够在utilities.js中的函数中使用utilities.js。
如何在chess.moves()内部使用utilities.js?
发布于 2021-07-12 15:07:32
在您导入的函数中传递国际象棋对象对您有用吗?
在你的utitilies.js里
let myNewFunction = (chess)=>{
chess.moves();
}
export myNewFunction;在你的app.js里
import Chess from 'chess.js';
import {myNewFunction } from './utilities';
let chess = new Chess();
....
myNewFunction(chess);
....https://stackoverflow.com/questions/68349678
复制相似问题