reactXp

2017-08-01  本文已影响0人  qlphsk

reactXp


XP means X-Platform

Share most of your code between the web, iOS, Android, and Windows.


COMPONENTS


APIS


项目搭建

由于reactXp并没有发布CLI工具,所有目前可以从GitHub上clone项目,然后把simple项目单独拿出来,进行修改。

RXPHelloWorld 运行

我们可以通过修改 App.tsx, 进行我们需要修改的功能.

安装依赖

运行 Web

运行android跟ios


运行指令

rn-watch

通过运行<a href="https://zhongsp.gitbooks.io/typescript-handbook/content/doc/handbook/tsconfig.json.html" target="_blank">tsconfig.json</a>文件,将文件打包成为js文件,到dist目录

但是并不会打包资源目录,所以资源目录需要自己copy过去


程序入口文件

index.tsx

import RX = require('reactxp');
import App = require('./App');

RX.App.initialize(true, true);
RX.UserInterface.setMainView(<App />);

整合react-navigation

const App = StackNavigator({
  Home: { screen: Apps },
  mall: { screen: Mall },
  prizeDetails:{ screen: PrizeDetails },
});

class rootView extends Component<null, null> {
    static navigationOptions = {
      title: 'Welcome',
    };

    render(): JSX.Element | null {
        return (
          <Provider store={store}>
            <View style={ {flex:1} }>
              <App />
            </View>
          </Provider>
        );
    }
}

export = rootView;

调用界面

this.props.navigation.navigate('mall');

控件调用

官方版本写法

import RX = require('reactxp');

<RX.View/>

可以换成以前的写法,不需要更改代码

import RX = require('reactxp');  //这一句不知道为何,去掉会出现错误
import {
  View,
  Text,
  Link,
  Animated,
  Styles,
  Component,
  Button,
} from 'reactxp';

web版本

由于babel的配置及tsconfig配置的问题,直接将项目复制过来在web端还存在一些问题,并且官方并没有文档介绍,所以暂时还无法解决。

结言

暂时感觉还只是一个比较简陋的版本,甚至连CLI都没有,感觉暂时还无法在实际项目中使用,坑实在有点多,文档非常不完善,例子程序也没内容

上一篇 下一篇

猜你喜欢

热点阅读