Skip to content

Commit

Permalink
同时运行在iOS和Android上
Browse files Browse the repository at this point in the history
  • Loading branch information
EleTeam committed Sep 10, 2016
1 parent a7e2b2e commit 8d806ab
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
17 changes: 16 additions & 1 deletion README-DOC.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
代码托管在: http://t.cn/Rc4mP0l

# 参考开源项目
react-native-iShiWuPai //初始化项目+redux
https://github.com/ljunb/react-native-iShiWuPai //初始化项目+redux
react-native-redux-demo //redux登录demo
demoJD
https://github.com/jiangqqlmj/GaGaMall 点餐商城
https://github.com/JasonStu/ReactNative_Shopping 实现电商基础界面和购物车功能

# 安卓的问题
1.启动安卓AVD虚拟模拟器
$android avd
2.选中Emulator, 点击start, 就能启动Emulator
3. $react-native run-android
4.查看对应的安卓设备
$ adb devices
新建安卓AVD虚拟模拟器
http://jingyan.baidu.com/article/a681b0ded7e7573b1943465b.html

# 需要更改原生文件的组件
react-native-vector-icons https://www.npmjs.com/package/react-native-vector-icons
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
取消注释, 在文件: app/common/constants_url.js:
const kUrlHost = 'http://eleteamapi.ygcr8.com/v1'; //在线服务器

#### 安装出现问题
1. Application Shop-React-Native has not been registered. This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent
解决办法:
造成这种错误有两种情况:
1. AppRegistry.registerComponent('项目名', () => 项目名); 与./ios/项目名/appDelegate.m中的RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"项目名" initialProperties:nil launchOptions:launchOptions]; 不同
在Android项目中可能是./android/app/src/main/java/com/项目名/MainActivity.java中的mReactRootView.startReactApplication(mReactInstanceManager, "项目名", null); 没有保持一致,修改方法:编辑成相同的参数即可。
2. 有可能你同时在运行一个以上的程序。如果你的react-native在运行程序A而你打开了程序B,也会出现相同的问题。解决方法:关闭其它React Native程序, 只运行一个。

### 部分App界面:
![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/01.png) ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/02.jpg) ![](https://github.com/EleTeam/Shop-React-Native/blob/master/screenshoot/03.jpg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.oblador.vectoricons.VectorIconsPackage;

import java.util.Arrays;
import java.util.List;
Expand All @@ -23,7 +24,8 @@ protected boolean getUseDeveloperSupport() {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
new MainReactPackage(),
new VectorIconsPackage()
);
}
};
Expand Down
19 changes: 7 additions & 12 deletions app/pages/ProductPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export default class ProductPage extends Component {
/>
{productReducer.isLoading ?
<Loading /> :
<View>
<Text>{product.name}</Text>
<Text>{product.name}</Text>
<View style={styles.content}>
<Text>{product.name}</Text>
<Text>{product.price}</Text>
</View>
Expand Down Expand Up @@ -93,17 +91,14 @@ class ToolBar extends React.Component {
}

const styles = StyleSheet.create({
webView: {
width: Common.window.width,
height: Common.window.height - 64 - 40,
container: {
flex: 1,
flexDirection:'row',
},

container: {
height: 40,
flexDirection: 'row',
alignItems: 'center',
borderTopColor: '#ccc',
borderTopWidth: 0.5,
content: {
width: Common.window.width,
height: Common.window.height - 64 - 40,
},

toolBarItem: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react": "15.2.1",
"react-native": "0.31.0",
"react": "15.3.1",
"react-native": "0.33.0",
"react-native-swiper": "^1.4.4",
"react-native-vector-icons": "^2.0.3",
"react-redux": "^4.4.5",
Expand Down

0 comments on commit 8d806ab

Please sign in to comment.