react native專案中時間計算異常問題

2022-01-31 12:39:58 字數 500 閱讀 5632

hermes存在部分機型,設定了時區,new date()返回值和jsc表現不一樣,有問題

描述:真機連線本地服務跑起來一切正常,斷開連線本地,就會有bug,由於new date導致算時間有問題,有相關時間計算的最後都顯示nan

機型: iphone11 oppo 等

原因 hermes有問題的時間格式:

new date('2019/11/21')

new date('2019-11-21')

new date('2019/11/21 10:00:00')

new date(2019,11,21,10,0,0,0)

hermes正常的時間格式:
new date()

new date().gettime()

new date('2019/11/21 10:00:00+0800')

解決方法: 把yyyy-mm-dd 字串時間格式,str.replace(/-/g,'/')

react native專案中遇到的問題

style sss 如下在父元件中呼叫子元件的寫法 父元件handleshowmodaladd this.add el 但是當我們在子元件中使用redux的時候,由於使用connect對子元件進行了包裝,會導致獲取不到子元件中的方法 下面的是使用redux後的ref使用方法 父元件handlesho...

React Native生成專案

使用cmd命令進入rn專案工程目錄,執行命令 react native init awesomeproject待檔案初始化完成之後,進入該專案目錄 cd awesomeproject執行專案 react native run android在編譯的過程中,會自動在裝置上設定除錯的位址,如果開啟程式一...

建立React Native 專案

適用版本 react native 0.62 安裝yarn 可以不安裝 npm install g yarnandroid配置環境變數 配置 android home 環境變數 新增環境變數 android home platform tools android home emulator andr...