我正在尝试创建一个列表数组,其中数组的每个元素在我的文本文件中都是一行。我已经尝试了以下方法,但是找不到访问arr对象的方法。有谁知道如何做到这一点?
fetch('file.txt')
.then(response => response.text())
.then(function (text) {
let arr = text.toString();
console.log(arr);
});
为什么不使用Fs模块读取您的file.txt,使用.split('')访问每个文本