1:安裝依賴的之前,沒有檢查對應(yīng)的node版本,在17版本下安裝了依賴,在xcode啟動(dòng)的時(shí)候報(bào)錯(cuò),如下:
# [Error message "error:0308010C:digital envelope routines::unsupported"]
解決方案:
- 切換node版本到16或者14(根據(jù)readMe去看對應(yīng)的依賴或者問老開發(fā)對應(yīng)的版本)
- 修改環(huán)境變量
// Linux&Mac OS(windows git bash)
export NODE_OPTIONS=--openssl-legacy-provider
// Windows command prompt-
set NODE_OPTIONS=--openssl-legacy-provider
附:Mac下修改環(huán)境變量流程
// 打開一個(gè)窗口光標(biāo)移動(dòng)到終端,command+ N代開一個(gè)新的窗口
command + N
// 在一個(gè)新窗口中建立多個(gè)終端窗口
command + T
// 查看當(dāng)前變量值
echo $PATH
// 查看.bash_profile文件
sudo vi ~/.bash_profile
// 點(diǎn)擊i進(jìn)行修改 然后:wq推出保存
//讀取執(zhí)行
source ~/.bash_profile
2.# react-native項(xiàng)目啟動(dòng)時(shí)報(bào)錯(cuò):Module AppRegistry is not registered callable module (calling runApplication)
1.結(jié)束所有的node進(jìn)程(Mac OS系統(tǒng)下可執(zhí)行 killall -9 node)
2.npm start(或者在xcode啟動(dòng)app即可)
3.獲取設(shè)備的高度和寬度
import { Dimensions } from “react-native”;
你可以用下面的方法來獲取設(shè)備的寬高:
const windowWidth = Dimensions.get(“window”).width;
const windowHeight = Dimensions.get(“window”).height;
4.文本換行
flexWrap: wrap,
flex: 1,
5.Remove alpha channel in an image
Open the image
Command-Shift-S to Duplicate (creates a copy)
Command-S to Save
Deselect the "Alpha" checkbox
Delete " copy" from filename (including the space)
This will overwrite your original, if you want to keep the original, just leave "copy" in the name
Save
Click 'Replace' to confirm you want to overwrite the original
Only necessary if you are overwriting your original