小编sin*_*kng的帖子

React Navigation:“导航”对象尚未初始化

我正在通过 https://reactnavigation.org/docs/en/upgrading-from-4.x.htmlhttps://reactnavigation.org/docs/en/compatibility.html将 React Navigation 库从 4.xx 升级到 5 。

我收到错误:

NavigationDebug Error:  Error: The 'navigation' object hasn't been initialized yet. This might happen if you don't have a navigator mounted, or if the navigator hasn't finished mounting. You can ensure that all navigators have mounted after the callback to 'useEffect' is called in your root component. See https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html#handling-initialization for more details.
    at dispatch (BaseNavigationContainer.tsx:202)
    at Object.acc.<computed> [as navigate] (BaseNavigationContainer.tsx:245)
    at Object.navigate (NavigationService.ts:20)
    at SplashScreen.redirectUser (splash-screen.tsx:234)
    at SplashScreen.proxiedMethod …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

7
推荐指数
1
解决办法
1万
查看次数

N位数的二进制数

在生成二进制数n
我这样做是为了得到高达16张二进制数.

n = 6                       # for 6 digits
for i in xrange(16):
    b = bin(i)[2:]
    l = len(b)
    b = str(0) * (n - l) + b
    print b
Run Code Online (Sandbox Code Playgroud)

结果是这样的

000000
000001
000010
000011
000100
000101
000110
000111
001000
001001
001010
001011
001100
001101
001110
001111
Run Code Online (Sandbox Code Playgroud)

但我想要的是获得这些值而不添加一系列的0s前缀.
任何人都可以帮助我.
谢谢

python string binary python-2.7

4
推荐指数
2
解决办法
5486
查看次数

从c ++中的函数返回数组

这个我的程序从c ++中的函数返回数组

#include <iostream>
using namespace std;

int *pTest(){
    static int a[] = {2,3,4,6,9};
    return a;
}

int main(){
    int *x;
    x = pTest();
    while(*x != NULL){
        cout << *x++ << "  ";
    }
}
Run Code Online (Sandbox Code Playgroud)

根据我的输出应该是2 3 4 6 9
我的机器输出2 3 4 6 9 1,
为什么1在输出中有额外的.
我正在使用codeblocks,gcc 4.8.1

c++ arrays pointers codeblocks

0
推荐指数
1
解决办法
107
查看次数