小编Jam*_* S.的帖子

React-Native:底部选项卡导航器:“tabBarOptions”已弃用。将选项迁移到“screenOptions”

我正在使用 React Native 开发一个移动应用程序,并在其中使用 Tab.Navigator - Tab.Screen 组件。在导航器中,我使用initialRouteNametabBarOptionsscreenOptions属性。在 javaScript 找到screenOptions之前,其他属性一切正常。然后它给我警报:

// Place the following in 'screenOptions' in your code to keep current behavior:

{
   "tabBarStyle": [
    {
      "display": "flex"
    },
    null
   ]
}
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅https://reactnavigation.org/docs/bottom-tab-navigator#options

我已经在我的代码中做到了:

const App = () => {
     return (
       <>
      <NavigationContainer>
        <Tab.Navigator
          initialRouteName='ExerciseScreensStack'
          tabBarOptions={{
            tabBarActiveTintColor: '#efb810',
            tabBarInactiveTintColor: 'black'
          }}
          screenOptions = {({ route }) =>({
            tabBarStyle: [
              {
                display: "flex"
              },
              null
            ],
        tabBarIcon: ({ color …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-tabnavigator

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

任何 npm 命令都会返回错误“找不到模块 yallist”,甚至 npm -v

(node:2564) UnhandledPromiseRejectionWarning: Error: Cannot find module 'yallist'
Require stack:
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\lru-cache\index.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\range.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\comparator.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\lib\cli.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
        at Function.Module._load (internal/modules/cjs/loader.js:746:27)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        at require (internal/modules/cjs/helpers.js:93:18)
        at Object.<anonymous> (C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\lru-cache\index.js:4:17)
        at Module._compile (internal/modules/cjs/loader.js:1085:14)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
        at Module.load (internal/modules/cjs/loader.js:950:32)
        at Function.Module._load (internal/modules/cjs/loader.js:790:12)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        (Use `node --trace-warnings ...` to show where the warning was created)
        (node:2564) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error 
        originated either by throwing inside of an async function …
Run Code Online (Sandbox Code Playgroud)

npm

5
推荐指数
1
解决办法
4984
查看次数

拆分串联函数并保留分隔符

我正在尝试拆分包含 python 函数的字符串,以便生成的输出将单独的函数保留为列表元素。
s='hello()there()'应该拆分为['hello()', 'there()']
为此,我使用正则表达式先行在右括号上拆分,但不在字符串末尾拆分。

虽然前瞻似乎有效,但我无法)按照各种帖子中的建议将结果保留在结果字符串中。简单地用正则表达式分割会丢弃分隔符:

import re
s='hello()there()'
t=re.split("\)(?!$)", s)
Run Code Online (Sandbox Code Playgroud)

这导致:'hello(', 'there()']

s='hello()there()'
t=re.split("(\))(?!$)", s)
Run Code Online (Sandbox Code Playgroud)

将分隔符包装为一个组会导致)保留为一个单独的元素:与使用该函数的方法['hello(', ')', 'there()'] 一样:filter()

s='hello()there()'
u = list(filter(None, re.split("(\))(?!$)", s)))
Run Code Online (Sandbox Code Playgroud)

再次导致括号作为单独的元素:['hello(', ')', 'there()']

如何拆分这样的字符串以使函数在输出中保持完整?

python regex string split python-re

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

navigation.push 不是一个函数。(在'navigation.push(“EditProfile”)'中,'navigation.push'未定义)(React navigation V6)

我是 React Native 的新手,我正在尝试执行简单的堆栈导航。我让它在应用程序的另一部分工作(用户身份验证步骤)。一旦用户登录,我的代码就会输入另一个堆栈。这个堆栈导航器嵌套了一个选项卡导航器,这可能会导致问题?

无论哪种方式,我都无法执行从我的个人资料屏幕到编辑个人资料屏幕的推送。代码如下。

import React from 'react'
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import LoginScreen from './screens/LoginScreen';
import HomeScreen from './screens/HomeScreen';
import SignupScreen from './screens/SignupScreen';
import ProfileScreen from './screens/ProfileScreen';
import EditProfileScreen from './screens/EditProfileScreen';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Icon from 'react-native-vector-icons/Ionicons';

const Stack = createNativeStackNavigator()

const screenOptions = {

headerShown: false

}

export const SignedOutStack = () =\> (

\<NavigationContainer\>

\<Stack.Navigator

initialRouteName="LoginScreen"

screenOptions={screenOptions}

\\>

\<Stack.Screen

name="Login"

component={LoginScreen}

/\>

\<Stack.Screen

name='SignupScreen' …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-navigation-v6

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