1识藤、初始化React-native,執(zhí)行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文件栏尚,然后執(zhí)行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:
- Clear watchman watches:
watchman watch-del-all
. - Delete the
node_modules
folder:rm -rf node_modules && npm install
. - Reset packager cache:
rm -fr $TMPDIR/react-*
ornpm start -- --reset-cache
.
npm install --save react@16.0.0-alpha.6 react-native
3笔呀、Text標(biāo)簽的onPress
4幢踏、設(shè)置導(dǎo)航欄
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许师、導(dǎo)航控制器里實時修改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【藍(lán)色文件夾圖標(biāo)】的方式引入圖片的assets,否則引用不到圖片
8微渠、發(fā)布的腳本
pushy bundle --platform <ios|android>
會報錯 /-bash: syntax error near unexpected token `newline'/
經(jīng)查搭幻,這是因為腳本代碼里包含有特殊字符的原因
簡直是蠢哭了,此處應(yīng)該直接是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是合并后的新文件