react-native-jsc

npm version

适用Android、iOS

有问题反馈

在使用中有任何问题,欢迎反馈给我,也可以用以下联系方式跟我交流

添加到项目中

  1. Run npm install react-native-jsc --save or yarn add react-native-jsc
  2. react-native link react-native-jsc
  3. var Jsc = require('react-native-jsc');

方法

使用

import React, {
    Component
} from 'react';
import {
    AppRegistry,
    View
} from 'react-native';
import Jsc from 'react-native-jsc';


export default class RNApp extends Component {
    constructor(props) {
        super(props);
        this.state = {};
        // 这句只有android平台才使用
        Jsc.obtainPackage("com.j2ustc.example");
        Jsc.obtain("Example",function (obj,msg) {
            console.log(obj);
            Jsc.fun(obj,"getName",null,function(name,msg){
                console.log("getName:",name);
            })
            Jsc.fun(obj,"setName",["Tom"],function(){});
            Jsc.fun(obj,"getName",null,function(name,msg){
                console.log("getName:",name);
            })
            Jsc.release(obj);
        })
        Jsc.sFun("Example","name",["Jack"],function(ret,msg){
            console.log(ret);
        })
    }
    render() {
        return (
            <View></View>
        );
    }
}