从JavaScript代码内部反应本机访问strings.xml [英] React Native access strings.xml from inside javascript code
问题描述
是否有办法从Javascript代码内部访问android/app/src/main/res/values/strings.xml
中的当前值?我想为每个构建放置不同的终结点URL,但是我什至无法检测到react-native代码内部的构建类型,而不必诉诸__DEV__变量(可以从开发菜单中将其关闭)
Is there a way to access the current values from android/app/src/main/res/values/strings.xml
from inside Javascript code? I want to place different endpoint URLs for each build, but I'm failing even to detect the type of build inside react-native code without having to resort to the __DEV__ variable (which can be turned off from the dev menu)
推荐答案
The only way this might be possible would be building a bridge using native modules, https://facebook.github.io/react-native/docs/native-modules-android.html. Essential you can pass strings in JS to the native modules and have native function handle which string to grab and pass back to JS.
这篇关于从JavaScript代码内部反应本机访问strings.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!