reactnativecn / react-native-website

React Native 中文网
https://reactnative.cn
MIT License
216 stars 327 forks source link

rn项目如何打开.txt文件 #656

Closed gzh1612 closed 1 year ago

gzh1612 commented 1 year ago

新创建一个项目 在项目目录下创建 a.txt文件 想在App.js中使用这个文件并且以string类型输出。 该如何操作呢

sunnylqm commented 1 year ago

先配置metro https://github.com/facebook/metro/issues/176#issuecomment-435722042

然后可以直接import/require

gzh1612 commented 1 year ago

我用这个方法拿到的是一个number类型的编号,如何根据这个编号获取到文本中的内容呢?

gzh1612 commented 1 year ago

我用其他方法解决了这个问题,谢谢