Reactnative——安装React Navigation后无法运行项目
2024-10-19 04:34:18
运行
npm install --save react-navigation
后,运行
react-native run-android
报
解决方法:
1、react-native init NavTest (The cli is locally installed with this command)
2、deleted package-lock.json
3、npm install --save react-navigation
4、deleted the generated package-lock.json
5、npm install
6、react-native run android A little ugly, I don't know entirely what happened, but this worked. https://reactnavigation.org/ for sample code to run.
Or Copy this to index.android.js
import React, { Component } from 'react';
import {
AppRegistry,
Button,
} from 'react-native';
import {
StackNavigator,
} from 'react-navigation'; class HomeScreen extends Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigate } = this.props.navigation;
return (
<Button
title="Go to Jane's profile"
onPress={() =>
navigate('Profile', { name: 'Jane' })
}
/>
);
}
} class ProfileScreen extends Component{
static navigationOptions = {
title: 'Jane',
};
render() {
return (null);
}
} const NavTest= StackNavigator({
Home: { screen: HomeScreen },
Profile: { screen: ProfileScreen },
}); AppRegistry.registerComponent('NavTest', () => NavTest);
最新文章
- EasyUi 方法传递多个参数值得方法
- jquery实现nav的下拉
- 分析器错误 MvcApplication 找不到
- iis错误记录
- 浏览器兼容性小整理和一些js小问题(后面会继续更新)
- iOS - (几个 button 按钮之间的单选与多选)
- linux C socket
- solr 竞价排行
- php数组遍历 使用foreach
- GitHub的css/js文件给墙了的解决方法
- Android运用自己的标题栏
- BP神经网络的基本原理
- redis - 主从复制与主从切换
- [原]左右的移动&;lt;&;lt;&;gt;&;gt;&;lt;&;gt;jQuery的实现
- Quartz 代码调用Demo
- 图片懒加载、selenium和PhantomJS
- TI 开发板安装USB转串口驱动
- CSS实现响应式全屏背景图
- es6函数的扩展
- IBM MQ相关 ---- 系列文章
热门文章
- 连接字符串配置在App.config中
- Leetcode - 309. Best Time to Buy and Sell Stock with Cooldown
- inception v1-v3 &; Xception
- Linux电源管理(7)_Wakeup events framework【转】
- Windows PowerShell 入門(9)-エラー編
- linux系统网络相关问题
- 《转》return *this和 return this有什么区别?
- 缓存系列之五:通过codis3.2实现redis3.2.8集群的管理
- MSSQL—行转列
- atoi 和 itoa的实现