最近很多小伙伴都在问ReactNativeTabNavigator设置Tab切换和react做tab切换这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展Flex中TabNaviga
最近很多小伙伴都在问React Native TabNavigator 设置Tab切换和react做tab切换这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展Flex中TabNavigator设置Tabs样式、javascript-React-Navigation 3:使用createBottomTabNavigator和createStackNavigator打开模式、React Native BottomTabNavigator导航不起作用、React Native Navigation V5 Stack、BottomTab 和 Drawer Navigation等相关知识,下面开始了哦!
本文目录一览:- React Native TabNavigator 设置Tab切换(react做tab切换)
- Flex中TabNavigator设置Tabs样式
- javascript-React-Navigation 3:使用createBottomTabNavigator和createStackNavigator打开模式
- React Native BottomTabNavigator导航不起作用
- React Native Navigation V5 Stack、BottomTab 和 Drawer Navigation
React Native TabNavigator 设置Tab切换(react做tab切换)
主要代码如下:
const resetActionTab = NavigationActions.navigate({routeName: 'Tab',action: NavigationActions.navigate({ routeName: 'Home'}) }); this.props.navigation.dispatch(resetActionTab);
Flex中TabNavigator设置Tabs样式
1、设计思路
(1)设计一个TabNavigator,其中包含两个Tabs;
(2)设置Tabs样式
2、设计源码
Tabs.mxml:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" > <fx:Declarations> <!-- Define custom colors for use as fills. --> <mx:SolidColor id="sc1" color="0xADFF2F" alpha=".8"/> <mx:SolidColor id="sc2" color="0xADD8E6" alpha=".6"/> <!-- Define custom strokes for the columns. --> <mx:SolidColorstroke id="s1" color="0xADFF2F" weight="2"/> <mx:SolidColorstroke id="s2" color="0xADD8E6" weight="2"/> </fx:Declarations> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; .myTabs{ color:#FFFFFF; font-weight:bold; background-color:#6495ED; } .myTextTabs{ color:#8B0000; background-color:#97FFFF; font-weight:bold; } mx|TabNavigator{ tab-style-name:"myTabs"; first-tab-style-name:"myTabs"; last-tab-style-name:"myTabs"; selected-tab-text-style-name:"myTextTabs"; } </fx:Style> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] //学生数据绑定 private var studentArray:ArrayCollection = new ArrayCollection([ {sno:"2013010101",math:"96"},{sno:"2013010102",math:"89"},{sno:"2013010103",math:"87"},{sno:"2013010104",math:"90"},{sno:"2013010105",math:"78"},{sno:"2013010106",math:"69"},{sno:"2013010107",math:"92"},{sno:"2013010108",math:"80"},{sno:"2013010109",math:"60"},{sno:"2013010110",math:"89"} ]); [Bindable] //教师数据绑定 private var teacherArray:ArrayCollection = new ArrayCollection([ {tno:"2013010101",tscore:"96"},{tno:"2013010102",tscore:"99"},{tno:"2013010103",tscore:"77"},{tno:"2013010104",tscore:"70"},{tno:"2013010105",tscore:"98"},{tno:"2013010106",tscore:"79"},{tno:"2013010107",tscore:"82"},{tno:"2013010108",{tno:"2013010109",tscore:"80"},{tno:"2013010110",tscore:"79"} ]); ]]> </fx:Script> <mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"> <mx:TabNavigator width="100%" height="100%" fontSize="12" cornerRadius="8"> <s:NavigatorContent label="学生" width="100%" height="100%"> <mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"> <mx:ColumnChart id="column" dataProvider="{studentArray}" showdatatips="true" width="100%" height="100%" fontSize="12"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="sno" displayName="学号"/> </mx:horizontalAxis> <mx:series> <mx:ColumnSeries displayName="数学成绩" xField="sno" yField="math" fill="{sc1}" stroke="{s1}"/> </mx:series> </mx:ColumnChart> <mx:HBox width="100%" height="30"> <s:Label width="50%"/> <mx:Legend dataProvider="{column}"/> </mx:HBox> </mx:VBox> </s:NavigatorContent> <s:NavigatorContent label="教师" width="100%" height="100%" fontSize="12"> <mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"> <mx:ColumnChart id="column1" dataProvider="{teacherArray}" showdatatips="true" width="100%" height="100%" fontSize="12"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="tno" displayName="工号"/> </mx:horizontalAxis> <mx:series> <mx:ColumnSeries displayName="教师评分" xField="tno" yField="tscore" fill="{sc2}" stroke="{s2}"/> </mx:series> </mx:ColumnChart> <mx:HBox width="100%" height="30"> <s:Label width="50%"/> <mx:Legend dataProvider="{column1}"/> </mx:HBox> </mx:VBox> </s:NavigatorContent> </mx:TabNavigator> </mx:VBox> </s:Application>3、设计说明
(1)tab-style-name:设置所有tabs的样式类
(2)first-tab-style-name:设置第一个tabs的样式类
(3)last-tab-style-name:设置最后一个tabs的样式类
(4)selected-tab-text-style-name:设置选中的tabs中的text样式类
4、设计结果
(1)初始化时结果
(2)切换tabs
javascript-React-Navigation 3:使用createBottomTabNavigator和createStackNavigator打开模式
我知道以前曾问过这个问题,但仅适用于旧版本的反应导航.从那以后,一些事情发生了变化. createBottomTabNavigator使创建底部导航器的速度大大提高,并且功能jumpToIndex()不再存在.
我的问题是如何创建类似于Instagram的底部选项卡,其中第一,第二,第四和第五个导航按钮的行为与通常的选项卡导航器相同,而中间按钮(screen3)将打开模态screen3Modal.
我已经在react-navigation 3.x.x中使用createBottomTabNavigator和createStackNavigator对其进行了尝试.
import React,{ Component,} from 'react';
import { createBottomTabNavigator,createStackNavigator,createAppContainer,} from 'react-navigation';
import { Screen1,Screen2,Screen3,Screen4,Screen5 } from './screens';
const TabNavigator = createBottomTabNavigator({
screen1: { screen: Screen1,},screen2: { screen: Screen2,screen3: {
screen: () => null,navigationoptions: () => ({
tabBarOnPress: () => this.props.navigation.navigate('screen3Modal')
})
},screen4: { screen: Screen4,screen5: { screen: Screen5,});
const StackNavigator = createStackNavigator({
Home: { screen: TabNavigator },screen3Modal: { screen: Screen3,{
initialRouteName: 'Home',});
const StackNavigatorContainer = createAppContainer(StackNavigator);
export default class App extends Component {
render() {
return <StackNavigatorContainer />;
}
}
此代码创建选项卡导航和模式导航.可以从另一个屏幕打开模态,但是在选项卡导航器中无法使用.我得到未定义的错误消息不是对象(正在评估“ _this.props.navigation”)
import React,screen3: { screen: () => null,//this.props.navigation.navigate('screen3Modal')
screen4: { screen: Screen4,{
initialRouteName: 'screen3Modal',});
const StackNavigatorContainer = createAppContainer(StackNavigator);
export default class App extends Component {
render() {
return <StackNavigatorContainer />;
}
}
React Native BottomTabNavigator导航不起作用
您正在尝试访问导航,该导航作为一种道具传递给MenuFlatList组件,您应该在下面进行操作
<TouchableWithoutFeedback onPress={() => {
this.props.navigation.navigate('WebViewImprint');
}}>
导航中的任何屏幕组件都将收到一个“导航”道具,可用于导航到其他屏幕。
React Native Navigation V5 Stack、BottomTab 和 Drawer Navigation
如何解决React Native Navigation V5 Stack、BottomTab 和 Drawer Navigation?
我在我的项目中使用了底部、堆栈和抽屉导航。
我需要导航到事件页面而不添加到底部导航器。
我的问题:
如果我需要将一个组件导航到另一个组件而不将组件添加到底部导航器,这里给出了两个文件的代码 如果需要导航到事件页面,如果我在 Component 我可以导航到 Events Compnents。但它也在底部选项卡导航器中显示我不希望底部导航器中的这个组件。
App.js
import ''react-native-gesture-handler'';
import { StatusBar } from ''expo-status-bar'';
import React from ''react'';
import { StyleSheet,Text,View } from ''react-native'';
import { NavigationContainer } from ''@react-navigation/native'';
import { createDrawerNavigator } from ''@react-navigation/drawer'';
import {DrawerContent} from ''./Screens/DrawerContent'';
import {Events} from ''./Screens/Events''
import MainTabScreen from ''./Screens/Bottomtab''
const Drawer = createDrawerNavigator();
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator drawerContent={props => <DrawerContent {...props} />}>
<Drawer.Screen name="Home" component={MainTabScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,backgroundColor: ''#fff'',alignItems: ''center'',justifyContent: ''center'',},});```
BottomTab Screen.js
enter code here
```
import React from "react";
import { createStackNavigator } from "@react-navigation/stack";
import Icon from "react-native-vector-icons/Ionicons";
import { createMaterialBottomTabNavigator } from "@react-navigation/material-bottom-tabs";
import Home from "./HomeScreen";
import About from "./AboutUs";
import Contact from "./ContactUs";
import Test from "./Test";
import Events from "./Events";
const HomeStack = createStackNavigator();
const AboutStack = createStackNavigator();
const ContactStack = createStackNavigator();
const TestStack = createStackNavigator();
const Eventsstack = createStackNavigator();
const Tab = createMaterialBottomTabNavigator();
const MainTabScreen = () => (
<Tab.Navigator
initialRouteName="Home"
activeColor="#fff"
// style={{ backgroundColor: ''tomato'' }}
>
<Tab.Screen
name="Home"
component={HomeStackScreen}
options={{
tabBarLabel: "Home",tabBarColor: "#009387",tabBarIcon: ({ color }) => (
<Icon name="ios-home" color={color} size={26} />
),}}
/>
<Tab.Screen
name="ContactUs"
component={ContactStackScreen}
options={{
tabBarLabel: "Notifications",tabBarColor: "#1f65ff",tabBarIcon: ({ color }) => (
<Icon name="ios-notifications" color={color} size={26} />
),}}
/>
<Tab.Screen
name="About"
component={AboutStackScreen}
options={{
tabBarLabel: "Profile",tabBarColor: "#694fad",tabBarIcon: ({ color }) => (
<Icon name="ios-person" color={color} size={26} />
),}}
/>
<Tab.Screen
name="Test"
component={TestStackScreen}
options={{
tabBarLabel: "Search",tabBarColor: "#d02860",tabBarIcon: ({ color }) => (
<Icon name="ios-aperture" color={color} size={26} />
),}}
/>
{/* <Tab.Screen
name="Events"
component={EventsstackScreen}
options={{
tabBarLabel: "Search",}}
/> */}
</Tab.Navigator>
);
export default MainTabScreen;
const HomeStackScreen = ({ navigation }) => (
<HomeStack.Navigator
screenoptions={{
headerStyle: {
backgroundColor: "#009387",headerTintColor: "#fff",headerTitleStyle: {
fontWeight: "bold",}}
>
<HomeStack.Screen
name="Home"
component={Home}
options={{
title: "Home",headerLeft: () => (
<Icon.Button
name="ios-menu"
size={25}
backgroundColor="#009387"
onPress={() => navigation.openDrawer()}
></Icon.Button>
),}}
/>
</HomeStack.Navigator>
);
const ContactStackScreen = ({ navigation }) => (
<ContactStack.Navigator
screenoptions={{
headerStyle: {
backgroundColor: "#1f65ff",}}
>
<ContactStack.Screen
name="ContactUs"
component={Contact}
options={{
title: "ContactUs",headerLeft: () => (
<Icon.Button
name="ios-menu"
size={25}
backgroundColor="#1f65ff"
onPress={() => navigation.openDrawer()}
></Icon.Button>
),}}
/>
</ContactStack.Navigator>
);
const AboutStackScreen = ({ navigation }) => (
<AboutStack.Navigator
screenoptions={{
headerStyle: {
backgroundColor: "#694fad",}}
>
<AboutStack.Screen
name="About"
component={About}
options={{
title: "AboutUs",headerLeft: () => (
<Icon.Button
name="ios-menu"
size={25}
backgroundColor="#694fad"
onPress={() => navigation.openDrawer()}
></Icon.Button>
),}}
/>
</AboutStack.Navigator>
);
const TestStackScreen = ({ navigation }) => (
<TestStack.Navigator
screenoptions={{
headerStyle: {
backgroundColor: "#d02860",}}
>
<TestStack.Screen
name="Test"
component={Test}
options={{
title: "Test",headerLeft: () => (
<Icon.Button
name="ios-menu"
size={25}
backgroundColor="#d02860"
onPress={() => navigation.openDrawer()}
></Icon.Button>
),}}
/>
</TestStack.Navigator>
);
const EventsstackScreen = ({ navigation }) => (
<Eventsstack.Navigator screenoptions={{
headerStyle: {
backgroundColor: "#d02860",}}
>
<Eventsstack.Screen
name="Events"
component={Events}
options={{
title: "Events",}}
/>
</Eventsstack.Navigator>
);
这里给出了两个文件的代码如果需要导航到事件页面,如果我在
我需要调用 EventsstackScreen 而不添加到
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
我们今天的关于React Native TabNavigator 设置Tab切换和react做tab切换的分享就到这里,谢谢您的阅读,如果想了解更多关于Flex中TabNavigator设置Tabs样式、javascript-React-Navigation 3:使用createBottomTabNavigator和createStackNavigator打开模式、React Native BottomTabNavigator导航不起作用、React Native Navigation V5 Stack、BottomTab 和 Drawer Navigation的相关信息,可以在本站进行搜索。
本文标签: