有些是摘录过来的,都标记了来源 自己记录,以便查看
1.the development server returned response error code:500
windows 0.56.0版本报错
创建项目是指定react版本即可
react-native init TestDemo --verbose --version 0.55.4
来源于:https://blog.csdn.net/klo220/article/details/81391949
2.Fix babel-preset-react-native TransformError
https://blog.csdn.net/tyro_java/article/details/77435451
3.reactnative 0.43以上版本Navigator不能从react-native直接获取
需要安装 npm install react-native-deprecated-custom-components --save
然后在使用的地方导入
4.react native使用 mobx , can't find variable:Symbol
转自http://www.cnblogs.com/crazycode2/p/9459827.html
把mobx降版本到 4.3.1 . mobx-react降版本到 5.1.0 即可.
5.FlatList未居中
给FlatList一个paddingHorizontal可以使FlatList的item与屏幕两侧有边距,但是使用了onRefresh后布局会靠左。
这种情况应该给marginHorizontal而不是paddingHorizontal
6.判断字符串是否全为数字
let str = 'as1415435'
let paStr = parseInt(str).toString()
if (pastr !== 'NaN' && (paStr.length === str.length)) {
console.log('str字符串中全为数字')
}
7.reactnative配合mobx开发,使用SectionList组件内容不刷新
使用SectionList组件嵌套层级过深,mobx不会去监听数据的改变。
这种情况有几种解决方案:
①将SectionList数组改为普通数组,在数据后面加个.slice(),数据内部有数组的话需要单独将数组slice()。---优选此方案
②(强行)让mobx去监听。让mobx多监听一个数据,例如数组长度啊title啊等等。。。。
https://cn.mobx.js.org/best/pitfalls.html
https://www.jianshu.com/p/5d743203744d
8.莫名其妙包加载失败
gradlew clean
9.androd 依赖包和sdk版本不匹配报错
在根目录的build.gradle下加上下面这段(强制匹配为同一版本)
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
}
}
}
}
10.app重复启动...
按home键返回到桌面之后再打开居然重复启动了,你敢信....
ReactNative App只有一个activity入口的。
默认activity的启动模式为standard,标准模式。 这个模式一个栈中可以有多个实例,每次启动app都会重新实例化。
所以这里应该改变一下activity的启动模式 使用单例模式 singleInstance, 不会创建新的实例,除非此实例消亡
其他启动模式请自行百度了解。。。
11.无法加载文件 C:\Users\jijun.tang\AppData\Roaming\npm\yarn(vue).ps1,因为在此系统上禁止运行脚本
管理员启动windows powerShell
输入set-ExecutionPolicy RemoteSigned
选择是(Y)
来源于https://blog.csdn.net/wqnmlgbsz/article/details/100654258