import
React
{
Component
}
from
'react'
;
import
{
View
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
Text
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
StyleSheet
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
Image
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
Alert
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
NativeAppEventEmitter
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
//引用NativeAppEventEmitter组件进行监听Native端派发的事件
'react-native'
;
var
TestOJO
require
NativeModules
TestOJO
;
o2cFun
addListener
(
'eventName'
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
para
=
>
alert
'被OC触发'
'字典数据:\n name:'
+
name
+
'\n age:'
age
)
;
// 千万不要忘记忘记取消订阅,通常在componentWillUnmount函数中实现。
// o2cFun.remove();
export
default
class
Main
extends
Component
{
constructor
props
{
super
;
this
state
{
selectedTab
'home'
;
}
{
;
}
render
{
return
(
<
View
style
{
{
flex
1
alignItems
'center'
}
>
<
Text
styles
himiTextStyle
>
Himi
React
Native
系列教程
<
/
Text
>
Text
onPress
)
>
{
j2oFun1
'Himi'
12321
;
j2oFun2
{
502_155@-h" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(0,
age
:
502_155@-cn" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(206,
array
[
'hi,Himi'
'i,m'
'a array!'
]
;
j2oCallbackEvent
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
error
callBackEvents
{
if
{
console
error
;
else
{
'J2O带返回值'
'数组的三个值:\n[0]:'
[
]
'\n[1]:'
'\n[2]:'
2
;
}
;
}
>
JS
->
OC
>
Text
{
emitterO2J
;
}
OC
JS
>
/
View
>
;
}
;
styles
create
{
himiTextStyle
{
backgroundColor
'#eee'
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
color
'#f00'
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
fontSize
30
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
marginTop
70
502_155@-sy" style="margin:0px; padding:0px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
502_155@-line @R_
502_155@-striped-line" id="@R_
502_155@-5752e17b06a4b377541250-74" style="margin:0px; padding:0px 5px; border:0px; font-style:inherit; height:inherit; font-size:inherit!important; line-height:inherit!important; background-color:rgb(247,
;