【发布时间】:2018-12-04 10:45:45
【问题描述】:
我想使用 react native 从 Android 中的文本文件中读取单元格编号并将所有数据转换为字符串。
现在我在这里:
import RNFS from "react-native-fs";
const rootPath = RNFS.DocumentDirectoryPath;
readFile = async () => {
const path = rootPath + "/rn.txt";
var content = await RNFS.readFile(path, "utf8");
return content;
};
render() {
return (
<View style={styles.container}>
<Text>{JSON.stringify(this.readFile())}</Text>
</View>
);
}
我得到文本 {"_40":0,"_65":0,"_55":null,"_72":null} ,我不知道它来自哪里。
请有人提出工作示例。
【问题讨论】:
-
请定义“无效”。
-
@HoàngVũAnh 谢谢。 RNFS.ExternalDirectoryPath RNFS.ExternalStorageDirectoryPath 两者都在工作
标签: android react-native text-files read-data