美文网首页
ReactNative的坑坑洼洼

ReactNative的坑坑洼洼

作者: 路CLu | 来源:发表于2017-07-18 11:27 被阅读134次

1、初始化React-native,执行run-ios报错

PhaseScriptExecution Install\ Third\ Party /Users/scdzs5/wh/project/hpApp/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh

报错版本问题
切换成下面的版本就可以了:
"react": "16.0.0-alpha.6","react-native": "0.44.3"
具体操作:删除node-modules文件夹,修改pakage.json文件,然后执行npm install

也可以在初始化时直接指定版本
react-native init TravalApp --version 0.44.3

2、集成到ios,路径报错

error: bundling: UnableToResolveError: Unable to resolve module react/lib/ReactDebugCurrentFrame from /Users/roadc/Desktop/MyReactNative/reactComponent/node_modules/react-native/Libraries/Renderer/src/renderers/shared/fiber/ReactFiberContext.js: Module does not exist in the module map or in these directories:
/Users/roadc/Desktop/MyReactNative/reactComponent/node_modules/react-native/node_modules/react/lib
, /Users/roadc/Desktop/MyReactNative/reactComponent/node_modules/react/lib

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.

npm install --save react@16.0.0-alpha.6 react-native


Pasted Graphic.png

3、Text标签的onPress

1__#$!@%!#__Pasted Graphic.png Pasted Graphic 1.png

4、设置导航栏

2__#$!@%!#__Pasted Graphic.png

5、js 代理Proxy 获取对象属性的方法

var handler = {
    get: function(target, name){
        return name in target ? target[name] : 'No prop!';
    }
};

var p = new Proxy({}, handler);
p.a = 1;
p.b = 2;

console.log(p.a);    //1
console.log(p.b);    //2
console.log(p.c);    //No prop!

Target 里的属性可以直接获取

6、导航控制器里实时修改title

self.props.navigation.setParams({
                            title:params.nativeEvent.title
                        });

7、打包 打包后本地图片加载

react-native bundle --entry-file index.ios.js --bundle-output ./ios/./bundle/index.ios.jsbundle --platform ios --assets-dest ./ios/bundle --dev false

必须用Create folder references【蓝色文件夹图标】的方式引入图片的assets,否则引用不到图片

8、发布的脚本

pushy bundle --platform <ios|android>
会报错 /-bash: syntax error near unexpected token `newline'/
经查,这是因为脚本代码里包含有特殊字符的原因

简直是蠢哭了,此处应该直接是pushy bundle --platform ios

9、bsdiff的用法

1.生成拆分包:
命令:bsdiff old.file new.file add.patch ,即old.file是旧的文件,new.file是新更改变化的文件,add.patch是这两个文件的差异文件.
2.旧文件和差分包合成新文件:
命令:bspatch old.file createNew.file add.patch 其中createNew.file是合并后的新文件

相关文章

网友评论

      本文标题:ReactNative的坑坑洼洼

      本文链接:https://www.haomeiwen.com/subject/rctccxtx.html