简体   繁体   English

我可以将ReactJS Native中的值分配给Swift全局变量吗? 如果是这样,怎么办?

[英]Can I assign a value from ReactJS Native to a Swift global variable? If so, how?

Is there any (straightforward) way to assign the value of a Swift global variable (of double_t type) from ReactJS Native JavaScript? 是否有任何(直接)方法可以从ReactJS本机JavaScript中分配Swift全局变量(double_t类型)的值? Or (scaling back from an XY question) is there any other way to make a (floating-point) Number computed in ReactJS Native JavaScript, and access it from a .swift file? 或者(从XY问题缩减)是否还有其他方法可以生成在ReactJS Native JavaScript中计算的(浮点数)并从.swift文件访问它?

No. At least not directly. 不。至少不是直接。

You can make your own Native Module that React Native can call on and get data from. 您可以创建自己的本机模块 ,React Native可以调用该本机模块并从中获取数据。 This allows you to write some native code that has a method that can be called to deliver the info you need. 这使您可以编写一些本机代码,该本机代码具有可以调用以传递所需信息的方法。 Then you write some javascript to that calls that method. 然后,您编写一些JavaScript来调用该方法。

Note the Swift Specific documentation here. 请注意此处的Swift特定文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM