从JavaScript代码内部反应本机访问strings.xml [英] React Native access strings.xml from inside javascript code

查看:43
本文介绍了从JavaScript代码内部反应本机访问strings.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆