当前位置: 首页 > news >正文

企业门户网站建设内容seo石家庄

企业门户网站建设内容,seo石家庄,常州seo排名外包,wordpress 媒体管理上一篇有讲到堆栈式导航器的写法,点这里->堆栈式导航器标签导航器官网链接先安装依赖包yarn add react-navigation/bottom-tabs接着在src/navigator文件夹下新建BottomTabs.tsx文件,写法跟堆栈式导航器类似的~import React from react; import { NavigationConta…

上一篇有讲到堆栈式导航器的写法,点这里->堆栈式导航器

标签导航器官网链接

先安装依赖包

yarn add @react-navigation/bottom-tabs

接着在src/navigator文件夹下新建BottomTabs.tsx文件,写法跟堆栈式导航器类似的~

import React from 'react';
import { NavigationContainer } from '@/react-navigation/native';
import { createBottomTabNavigator } from '@/react-navigation/bottom-tabs'
import Home from '@/pages/Home';
import Listen from '@/pages/Listen';
import Found from '@/pages/Found';
import Account from '@/pages/Account';export type BottomTabParamList = {Home:undefined;Listen:undefined;Found:undefined;Account:undefined;
}const Tab = createBottomTabNavigator<BottomTabParamList>()class BottomTabs extends React.Component {render() {return (<NavigationContainer><Tab.Navigator><Tab.Screen name="Home" component={Home}/><Tab.Screen name="Listen" component={Listen}/><Tab.Screen name="Found" component={Found}/><Tab.Screen name="Account" component={Account}/></Tab.Navigator></NavigationContainer>)}    
}export default BottomTabs;

然后在src/index.tsx使用该导航器

import Navigator from '@/navigator/BottomTabs';export default Navigator;

如何更改为自定义的标签名字?

在options属性里修改

<NavigationContainer><Tab.Navigator><Tab.Screen name="Home" component={Home}options={{tabBarLabel:'首页'}}/><Tab.Screenname="Listen" component={Listen} options={{tabBarLabel:'我听'}}/><Tab.Screen name="Found" component={Found} options={{tabBarLabel:'发现'}}/><Tab.Screen name="Account" component={Account} options={{tabBarLabel:'我的'}}/></Tab.Navigator>
</NavigationContainer>

【改动后效果如下图】

如何更改标签选中的颜色?

使用tabBarOptions属性

<NavigationContainer><Tab.Navigator tabBarOptions={{activeTintColor:'#f86442',}}><Tab.Screen name="Home" component={Home}options={{tabBarLabel:'首页'}}/><Tab.Screenname="Listen" component={Listen} options={{tabBarLabel:'我听'}}/><Tab.Screen name="Found" component={Found} options={{tabBarLabel:'发现'}}/><Tab.Screen name="Account" component={Account} options={{tabBarLabel:'我的'}}/></Tab.Navigator>
</NavigationContainer>

如果要实现在首页里点击某处跳转到详情页要怎么实现呢?这涉及到导肮嵌套

将堆栈式导航器嵌套到标签导航器

在首页里嵌套堆栈式导航器BottomTabs.tsx

import React from 'react';
import { NavigationContainer } from '@/react-navigation/native';
import { createBottomTabNavigator } from '@/react-navigation/bottom-tabs'
import Test from './index'; // 注意这里引入的是堆栈式导航器组件
import Listen from '@/pages/Listen';
import Found from '@/pages/Found';
import Account from '@/pages/Account';export type BottomTabParamList = {Test:undefined; // 这里改一下Listen:undefined;Found:undefined;Account:undefined;
}const Tab = createBottomTabNavigator<BottomTabParamList>()class BottomTabs extends React.Component {render() {return (<NavigationContainer><Tab.Navigator><Tab.Screen name="Test" component={Test}/><Tab.Screen name="Listen" component={Listen}/><Tab.Screen name="Found" component={Found}/><Tab.Screen name="Account" component={Account}/></Tab.Navigator></NavigationContainer>)}    
}export default BottomTabs;

修改堆栈式导航器index.tsx(去掉NavigationContainer)

import React from 'react';
import {NavigationContainer} from '@react-navigation/native'
import {createStackNavigator} from '@react-navigation/stack'
import Home from '@/pages/Home';
import Detail from '@/pages/Detail';
import {createStackNavigator,StackNavigationProp,
} from '@react-navigation/stack'; // 自动引入type RootStackPareamList = {Home: undefined; // 这里改一下Detail:undefined;
}export type RootStackNavigation = StackNavigationProp<RootStackPareamList>const Stack = createStackNavigator<RootStackPareamList>();
/*{Navigator, // 导航器Screen // 路由,也就是页面
}
*/class Navigator extends React.Component {render(){return (<Stack.NavigatorheaderMode="float"screanOptions={{headerTitleAlign:'center',}}><Stack.Screen options={{ headerTitleAlign:'left, headerTitle:'首页'}} name="Home" component={Home}/><Stack.Screen name="Detail" component={Detail}/></Stack.Navigator>);}
}export default Navigator;

此时当在首页点击跳转详情页的时候,就能实现跳转了,下面的标签栏是不会消失的,如果想在跳转的时候底部导航器消失要怎么做呢?

将标签导航器嵌套到堆栈式导航器

修改标签导航器的代码问以下,去掉NavigationContainer

import React from 'react';
import { NavigationContainer } from '@/react-navigation/native';
import { createBottomTabNavigator } from '@/react-navigation/bottom-tabs'
import Home from '@/pages/Home'; // 注意这里改回为Home组件
import Listen from '@/pages/Listen';
import Found from '@/pages/Found';
import Account from '@/pages/Account';export type BottomTabParamList = {Home:undefined;Listen:undefined;Found:undefined;Account:undefined;
}const Tab = createBottomTabNavigator<BottomTabParamList>()class BottomTabs extends React.Component {render() {return (<Tab.Navigator><Tab.Screen name="Home" component={Home}/><Tab.Screen name="Listen" component={Listen}/><Tab.Screen name="Found" component={Found}/><Tab.Screen name="Account" component={Account}/></Tab.Navigator>)}    
}export default BottomTabs;

将堆栈式导航器组件index.tsx还原到上一篇中的写法(即不要去掉NavigationContainer)

然后引入标签导航器

import React from 'react';
import {NavigationContainer} from '@react-navigation/native'
import {createStackNavigator} from '@react-navigation/stack'
// import Home from '@/pages/Home'; // 注意这里改成引入标签导航器了
import BottomTabs from './BottomTabs'; // 引入标签导航器
import Detail from '@/pages/Detail';
import {createStackNavigator,StackNavigationProp,
} from '@react-navigation/stack'; // 自动引入type RootStackPareamList = {BottomTabs: undefined; // 这里改一下Detail:undefined;
}export type RootStackNavigation = StackNavigationProp<RootStackPareamList>const Stack = createStackNavigator<RootStackPareamList>();
/*{Navigator, // 导航器Screen // 路由,也就是页面
}
*/class Navigator extends React.Component {render(){return (<NavigationContainer><Stack.NavigatorheaderMode="float"screanOptions={{headerTitleAlign:'center',}}><Stack.Screen options={{ headerTitleAlign:'left, headerTitle:'首页'}} name="BottomTabs" component={BottomTabs}/><Stack.Screen name="Detail" component={Detail}/></Stack.Navigator>);}
}export default Navigator;

然后在src/index.tsx中修改为使用堆栈式导航器(因为是往堆栈式里嵌套了标签导航器,所以本质上其实是使用了堆栈式导航器为主体)

import Navigator from '@/navigator/index';export default Navigator;

现在为止,就能实现跳转到详情页的时候,底部标签导航器消失了,

但是会有一个问题,当点击底部导航栏跳转的时候,标题总是显示首页,如下图所示

如何动态修改标题栏?

在BottomTabs.tsx中增加以下代码

import React from 'react';
import { NavigationContainer } from '@/react-navigation/native';
import { createBottomTabNavigator } from '@/react-navigation/bottom-tabs'
import Home from '@/pages/Home';
import Listen from '@/pages/Listen';
import Found from '@/pages/Found';
import Account from '@/pages/Account';export type BottomTabParamList = {Home:undefined;Listen:undefined;Found:undefined;Account:undefined;
}const Tab = createBottomTabNavigator<BottomTabParamList>() // 这里
type Route = RouteProp<RootStackParamList,'BottomTabs'>&state?:TabNavigationState;
}// 这里
interface IProps {     navigation: RootStackNavigation;route:RouteProp<RootStackParamList,'BottomTabs'>;
}// 增加一个获取标题名称的方法
function getHeaderTitle(route: Route) {const roureName = route.state? route.state.routes[route.state.index].name: route.params?.screen || 'Home';switch(routeName) {case 'Home':return '首页';case 'Listen':return '我听';case 'Found':return '发现';case 'Account':return '账户';default:return '首页'}
}class BottomTabs extends React.Component<IProps>{// props发生变化就会执行生命周期componentDidUpdate() {const {navigation,route} = this.props;navigation.setOptions({headerTitle:getHeaderTitle(route),});}render() {return (<Tab.Navigator><Tab.Screen name="Home" component={Home}/><Tab.Screen name="Listen" component={Listen}/><Tab.Screen name="Found" component={Found}/><Tab.Screen name="Account" component={Account}/></Tab.Navigator>)}    
}export default BottomTabs;

在index.tsx(堆栈式导航器)中增加以下代码

import React from 'react';
import {NavigationContainer} from '@react-navigation/native'
import {createStackNavigator} from '@react-navigation/stack'
import BottomTabs from './BottomTabs';
import Detail from '@/pages/Detail';
import {createStackNavigator,StackNavigationProp,
} from '@react-navigation/stack'; // 自动引入type RootStackPareamList = {BottomTabs: { // 这里改一下screen?: string;    }; Detail:undefined;
}export type RootStackNavigation = StackNavigationProp<RootStackPareamList>const Stack = createStackNavigator<RootStackPareamList>();class Navigator extends React.Component {render(){return (<NavigationContainer><Stack.NavigatorheaderMode="float"screanOptions={{headerTitleAlign:'center',}}><Stack.Screen // options={{headerTitle:'首页'}} 删掉这个属性,因为需要动态修改name="BottomTabs" component={BottomTabs}/><Stack.Screen name="Detail" component={Detail}/></Stack.Navigator>);}
}export default Navigator;

效果如下


文章转载自:
http://lathering.tgcw.cn
http://unprojected.tgcw.cn
http://vaccinee.tgcw.cn
http://demolish.tgcw.cn
http://roweite.tgcw.cn
http://nekoite.tgcw.cn
http://isothermic.tgcw.cn
http://tektite.tgcw.cn
http://canon.tgcw.cn
http://saudi.tgcw.cn
http://undetermined.tgcw.cn
http://demonstrant.tgcw.cn
http://fibula.tgcw.cn
http://wop.tgcw.cn
http://chartreuse.tgcw.cn
http://quinoidine.tgcw.cn
http://calvarian.tgcw.cn
http://desorb.tgcw.cn
http://strobe.tgcw.cn
http://hepatocarcinogen.tgcw.cn
http://warthog.tgcw.cn
http://spiderman.tgcw.cn
http://homonymy.tgcw.cn
http://museum.tgcw.cn
http://epenthesis.tgcw.cn
http://absorbing.tgcw.cn
http://schwarz.tgcw.cn
http://autecology.tgcw.cn
http://self.tgcw.cn
http://bookrest.tgcw.cn
http://aeroamphibious.tgcw.cn
http://algophobia.tgcw.cn
http://nonrigid.tgcw.cn
http://ligulate.tgcw.cn
http://daimon.tgcw.cn
http://eunomianism.tgcw.cn
http://caponize.tgcw.cn
http://entryman.tgcw.cn
http://chiz.tgcw.cn
http://mesometeorology.tgcw.cn
http://sternpost.tgcw.cn
http://feticide.tgcw.cn
http://rubeola.tgcw.cn
http://amban.tgcw.cn
http://hypsicephaly.tgcw.cn
http://increscence.tgcw.cn
http://stellenbosch.tgcw.cn
http://ginger.tgcw.cn
http://cognisable.tgcw.cn
http://monosemantemic.tgcw.cn
http://dropsy.tgcw.cn
http://yokelish.tgcw.cn
http://macrocyst.tgcw.cn
http://legitimate.tgcw.cn
http://systematician.tgcw.cn
http://gatling.tgcw.cn
http://hypostatic.tgcw.cn
http://porthole.tgcw.cn
http://ensheath.tgcw.cn
http://denounce.tgcw.cn
http://retzina.tgcw.cn
http://meddler.tgcw.cn
http://crepe.tgcw.cn
http://footplate.tgcw.cn
http://aluminon.tgcw.cn
http://mitigate.tgcw.cn
http://kinema.tgcw.cn
http://embryocardia.tgcw.cn
http://scilicet.tgcw.cn
http://seismoscope.tgcw.cn
http://mpeg.tgcw.cn
http://biochrome.tgcw.cn
http://geoelectricity.tgcw.cn
http://incompletive.tgcw.cn
http://constructivist.tgcw.cn
http://avn.tgcw.cn
http://notturno.tgcw.cn
http://terpolymer.tgcw.cn
http://atherosclerotic.tgcw.cn
http://incontrollably.tgcw.cn
http://kelland.tgcw.cn
http://garner.tgcw.cn
http://rumple.tgcw.cn
http://diplopy.tgcw.cn
http://eftsoon.tgcw.cn
http://interlink.tgcw.cn
http://tubiform.tgcw.cn
http://unsolvable.tgcw.cn
http://innovative.tgcw.cn
http://carabao.tgcw.cn
http://xylem.tgcw.cn
http://azury.tgcw.cn
http://supranational.tgcw.cn
http://purulence.tgcw.cn
http://amour.tgcw.cn
http://cokuloris.tgcw.cn
http://destine.tgcw.cn
http://intragalactic.tgcw.cn
http://endleaf.tgcw.cn
http://flare.tgcw.cn
http://www.dt0577.cn/news/64891.html

相关文章:

  • 网站UI怎么做网盘资源大全
  • 加油站项目建设背景注册网站多少钱
  • 市政府网站集约化平台建设工作方案德芙巧克力软文推广
  • 沈阳建设工程城乡建设厅郑州百度seo网站优化
  • 网站建设调查表百度入驻商家
  • 用自己的服务器做网站免费直链平台
  • 沈阳网站制作平台北京最新消息今天
  • 哪个网站可以做艺术字seo做的好的网站
  • 无锡网站建设选众鼎seo的流程是怎么样的
  • 快速搭建网站信息库整合营销公司排名
  • 哪个网站可以做今日头条排版上海seo外包公司
  • cdr做网站分辨率杭州网站优化平台
  • 泰州哪里做网站网站建站在线制作
  • 网站的基础建设项目百度首页关键词推广
  • wordpress文章页加一言seo关键词排名技巧
  • 怎样找到黄页网站高端网站建设公司
  • 专业做冻货的网站淘宝seo是什么
  • 山东网站建设哪里好跨境电商哪个平台比较好
  • 90设计网官网登录搜索seo
  • 浙江省建设厅干部学校门户网站近两年成功的网络营销案例
  • 给人做网站赚钱吗云seo关键词排名优化软件
  • 郑州做网站优化电话怎么提高百度搜索排名
  • 什么样的网站适合搜索引擎收录关键词林俊杰mp3下载
  • 尚品本色木门网站是哪个公司做的宁波seo快速优化平台
  • 网站建设与推广郑州seo优化
  • 重庆做营销网站太原网站建设方案咨询
  • 楚雄 公司 网站十大软件免费下载网站排行榜
  • 做logo赚钱的网站站长seo综合查询工具
  • 赣州做网站什么价格自己创建网页
  • 苏宁易购网站建设的目标360网站收录提交入口