1. Live Reload和Hot Reloading的区别:
相同点:都是你只要保存一下原文件,那么App就会实时刷新。
区别:Live Reload是全局刷新,而Hot Reloading是局部刷新。
2. 有时候我们修改了代码,在手机上并不会实时更新代码。
解决的办法就是打开文件(是下面2个路径中的一个):文章来源地址:https://www.yii666.com/article/756332.html
app_name\node_modules\react-native\packager\react-packager\src\node-haste\FileWatcher\index.js
或 app_name\node_modules\react-native\node_modules\node-haste\lib\FileWatcher\index.js 文章地址https://www.yii666.com/article/756332.html
修改变量MAX_WAIT_TIME:
// var MAX_WAIT_TIME = 120000;
var MAX_WAIT_TIME = 360000;
3. ScrollView组件的样式不能用 style={} 来写,需要用 contentContainerStyle={}。
<ScrollView contentContainerStyle={[styles.flex1,styles.h_v_center]}>
4.由于react native没有br标签,需要换行只能将换行符插入:
{'\n'}
在字符串中用 \n 来代替。
5.有时候实现垂直居中,需要给元素加flex:1;这个样式。
6.不要给ScrollView加flex:1;这个样式,否则无法出现滚动条。
7.获得当前路由的名字(如果当前路由是首页,点击首页,不跳转):网址:yii666.com
_jumpToHome(){
const {navigator} = this.props;
const routers = navigator.getCurrentRoutes();
// routers[0].component.name:获取当前路由名字
// 如果当前路由是首页FirstPage,点击首页,不跳转
if(navigator && routers[0].component.name != "FirstPage"){
navigator.push({
name:'FirstPage',
component:FirstPage
})
}
}
8.windows目录:C:\Users\xxx\.gradle 里没有 gradle.properties 文件时,需要手动创建。
9.