中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

做外貿(mào)網(wǎng)站需要什么卡西安網(wǎng)站快速排名提升

做外貿(mào)網(wǎng)站需要什么卡,西安網(wǎng)站快速排名提升,文化傳媒網(wǎng)站建設(shè),清河網(wǎng)站制作簡(jiǎn)言 移動(dòng)應(yīng)用基本不會(huì)只由一個(gè)頁(yè)面組成。管理多個(gè)頁(yè)面的呈現(xiàn)、跳轉(zhuǎn)的組件就是我們通常所說(shuō)的導(dǎo)航器(navigator)。 React Navigation 提供了簡(jiǎn)單易用的跨平臺(tái)導(dǎo)航方案,在 iOS 和 Android 上都可以進(jìn)行翻頁(yè)式、tab 選項(xiàng)卡式和抽屜式的導(dǎo)航布局…

簡(jiǎn)言

移動(dòng)應(yīng)用基本不會(huì)只由一個(gè)頁(yè)面組成。管理多個(gè)頁(yè)面的呈現(xiàn)、跳轉(zhuǎn)的組件就是我們通常所說(shuō)的導(dǎo)航器(navigator)。
React Navigation 提供了簡(jiǎn)單易用的跨平臺(tái)導(dǎo)航方案,在 iOS 和 Android 上都可以進(jìn)行翻頁(yè)式、tab 選項(xiàng)卡式和抽屜式的導(dǎo)航布局。
React Navigation 中的視圖是原生組件,同時(shí)用到了運(yùn)行在原生線程上的Animated動(dòng)畫(huà)庫(kù),因而性能表現(xiàn)十分流暢。此外其動(dòng)畫(huà)形式和手勢(shì)都非常便于定制。

要想詳細(xì)了解 React Navigation 的具體用法,請(qǐng)?jiān)L問(wèn)其React Navigation官網(wǎng)。

本篇是在window系統(tǒng)android環(huán)境下使用,mac系統(tǒng)請(qǐng)查看官網(wǎng)。

React Navigation

安裝

官網(wǎng)安裝指南Doc
核心包安裝命令:

yarn add @react-navigation/native

除此之外,還要安裝:

yarn add react-native-screens react-native-safe-area-context

react-native-screens 軟件包需要一個(gè)額外的配置步驟才能在安卓設(shè)備上正常運(yùn)行。編輯位于 android/app/src/main/java// 下的 MainActivity.kt 或 MainActivity.java 文件:
kotlin 類型

class MainActivity: ReactActivity() {// ...override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(null)}// ...
}

或者java類型

public class MainActivity extends ReactActivity {// ...@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(null);}// ...
}

添加好后,在頂部添加新依賴包語(yǔ)句聲明:

import android.os.Bundle;

在這里插入圖片描述

需要做出這一更改,以避免因視圖狀態(tài)無(wú)法在活動(dòng)重啟時(shí)持續(xù)保持而導(dǎo)致崩潰。

使用

我們需要用 NavigationContainer 封裝整個(gè)應(yīng)用程序。通常,您會(huì)在入口文件(如 index.js 或 App.js)中這樣做:

import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';export default function App() {return (<NavigationContainer>{/* Rest of your app code */}</NavigationContainer>);
}

現(xiàn)在就可以正常運(yùn)行了。

navigator

導(dǎo)航器 ,上面我們只是安裝了React Navigation基礎(chǔ),并沒(méi)有真正使用導(dǎo)航功能。
實(shí)現(xiàn)導(dǎo)航功能需要安裝對(duì)應(yīng)的navigator 才可以。
6.x版本的navigator 有以下幾種:
在這里插入圖片描述

Stack Navigator 堆棧導(dǎo)航器

堆棧導(dǎo)航器為您的應(yīng)用程序提供了一種在屏幕間轉(zhuǎn)換的方法,每個(gè)新屏幕都被放置在堆棧的頂部。
這種導(dǎo)航器和web的history stack比較相像。

雖然 @react-navigation/stack 可定制性極強(qiáng),但它是用 JavaScript 實(shí)現(xiàn)的。雖然它可以使用本機(jī)運(yùn)行動(dòng)畫(huà)和手勢(shì),但性能可能不如本機(jī)實(shí)現(xiàn)的快。

安裝:

yarn add @react-navigation/stack

然后,需要安裝和配置堆棧導(dǎo)航器所需的庫(kù):

yarn add react-native-gesture-handler

要最終完成 react-native-gesture-handler 的安裝,請(qǐng)?jiān)谌肟谖募?#xff08;如 index.js 或 App.js)的頂部添加以下內(nèi)容(確保它位于頂部,且之前沒(méi)有其他內(nèi)容)

import 'react-native-gesture-handler';

例子:

import { createStackNavigator } from '@react-navigation/stack';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內(nèi)容Feed</Text>;
}
function Settings() {return <Text>top內(nèi)容Settings</Text>;
}
function Profile() {return <Text>top內(nèi)容Profile</Text>;
}
const Stack = createStackNavigator();function MyStack() {return (<Stack.NavigatorinitialRouteName="Home"screenOptions={{headerMode: 'screen',headerTintColor: 'white',headerStyle: { backgroundColor: 'tomato' },}}><Stack.Screenname="Home"component={Home}options={{title: 'Awesome app',}}/><Stack.Screenname="Profile"component={Profile}options={{title: 'My profile',}}/><Stack.Screenname="Settings"component={Settings}options={{gestureEnabled: false,}}/></Stack.Navigator>);
}

Native Stack Navigator 原生堆棧導(dǎo)航器

導(dǎo)航器使用 iOS 上的 UINavigationController 和 Android 上的 Fragment 原生 API,因此使用 createNativeStackNavigator 構(gòu)建的導(dǎo)航器將與基于這些 API 構(gòu)建的應(yīng)用程序具有完全相同的行為和性能特征。它還使用 react-native-web 提供基本的 Web 支持。

雖然 @react-navigation/native-stack 提供了原生性能并暴露了原生功能,如 iOS 上的大標(biāo)題等,但它可能不如 @react-navigation/stack 可定制,這取決于您的需求。

安裝:

yarn add @react-navigation/native-stack

例子:

import { createNativeStackNavigator } from '@react-navigation/native-stack';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內(nèi)容Feed</Text>;
}
function Settings() {return <Text>top內(nèi)容Settings</Text>;
}
function Profile() {return <Text>top內(nèi)容Profile</Text>;
}
const Stack = createNativeStackNavigator();function MyStack() {return (<Stack.NavigatorinitialRouteName="Home"screenOptions={{headerTintColor: 'white',headerStyle: { backgroundColor: 'tomato' },}}><Stack.Screenname="Home"component={Home}options={{title: 'Awesome app',}}/><Stack.Screenname="Profile"component={Profile}options={{title: 'My profile',}}/><Stack.Screenname="Settings"component={Settings}options={{gestureEnabled: false,}}/></Stack.Navigator>);
}

Drawer Navigator 抽屜導(dǎo)航器

抽屜導(dǎo)航器在屏幕一側(cè)顯示一個(gè)導(dǎo)航抽屜,可通過(guò)手勢(shì)打開(kāi)或關(guān)閉。
在這里插入圖片描述
安裝:

yarn add @react-navigation/drawer
yarn add react-native-gesture-handler react-native-reanimated

要最終完成 react-native-gesture-handler 的安裝,請(qǐng)?jiān)谌肟谖募?#xff08;如 index.js 或 App.js)的頂部(確保位于頂部,且之前沒(méi)有其他內(nèi)容)添加以下內(nèi)容

import 'react-native-gesture-handler';

react-native-reanimated安裝后,也要在babel.config.js上加下配置:

module.exports = {plugins: ['react-native-reanimated/plugin'],
};

不加在編譯時(shí)會(huì)報(bào)react-native-reanimated相關(guān)的錯(cuò)誤。

例子:

import { createDrawerNavigator } from '@react-navigation/drawer';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內(nèi)容Feed</Text>;
}
function Notifications() {return <Text>top內(nèi)容Notifications</Text>;
}
function Profile() {return <Text>top內(nèi)容Profile</Text>;
}
const Drawer = createDrawerNavigator();function MyDrawer() {return (<Drawer.Navigator initialRouteName="Feed"><Drawer.Screenname="Feed"component={Feed}options={{ drawerLabel: 'Home' }}/><Drawer.Screenname="Notifications"component={Notifications}options={{ drawerLabel: 'Updates' }}/><Drawer.Screenname="Profile"component={Profile}options={{ drawerLabel: 'Profile' }}/></Drawer.Navigator>);
}

Bottom Tabs Navigator 底部Tab導(dǎo)航器

屏幕底部有一個(gè)簡(jiǎn)單的標(biāo)簽欄,讓你能在不同路線之間切換。路由是懶散初始化的,只有在首次聚焦時(shí)才會(huì)安裝其屏幕組件。
安裝:

yarn add @react-navigation/bottom-tabs

例子:

例子使用了react-native-vector-icons 圖標(biāo)庫(kù),使用前記得下載安裝安裝參考

import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內(nèi)容Feed</Text>;
}
function Notifications() {return <Text>top內(nèi)容Notifications</Text>;
}
function Profile() {return <Text>top內(nèi)容Profile</Text>;
}
const Tab = createBottomTabNavigator();function MyTabs() {return (<Tab.NavigatorinitialRouteName="Feed"screenOptions={{tabBarActiveTintColor: '#e91e63',}}><Tab.Screenname="Feed"component={Feed}options={{tabBarLabel: 'Home',tabBarIcon: ({ color, size }) => (<MaterialCommunityIcons name="home" color={color} size={size} />),}}/><Tab.Screenname="Notifications"component={Notifications}options={{tabBarLabel: 'Updates',tabBarIcon: ({ color, size }) => (<MaterialCommunityIcons name="bell" color={color} size={size} />),tabBarBadge: 3,}}/><Tab.Screenname="Profile"component={Profile}options={{tabBarLabel: 'Profile',tabBarIcon: ({ color, size }) => (<MaterialCommunityIcons name="account" color={color} size={size} />),}}/></Tab.Navigator>);
}

Material Bottom Tabs Navigator

Material風(fēng)格的底部標(biāo)簽導(dǎo)航器。
官網(wǎng)參考指南

Material Top Tabs Navigator

頂部標(biāo)簽導(dǎo)航器
安裝:

yarn add @react-navigation/material-top-tabs react-native-tab-view
yarn add react-native-pager-view

例子:

import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內(nèi)容Feed</Text>;
}
function Notifications() {return <Text>top內(nèi)容Notifications</Text>;
}
function Profile() {return <Text>top內(nèi)容Profile</Text>;
}
const Tab = createMaterialTopTabNavigator();function MyTabs() {return (<Tab.NavigatorinitialRouteName="Feed"screenOptions={{tabBarActiveTintColor: '#e91e63',tabBarLabelStyle: { fontSize: 12 },tabBarStyle: { backgroundColor: 'powderblue' },}}><Tab.Screenname="Feed"component={Feed}options={{ tabBarLabel: 'Home' }}/><Tab.Screenname="Notifications"component={Notifications}options={{ tabBarLabel: 'Updates' }}/><Tab.Screenname="Profile"component={Profile}options={{ tabBarLabel: 'Profile' }}/></Tab.Navigator>);
}

效果

在這里插入圖片描述
在這里插入圖片描述

結(jié)語(yǔ)

這幾種navigator 可以隨意嵌套使用,具體使用方法請(qǐng)到官方網(wǎng)站閱覽。

http://www.risenshineclean.com/news/33433.html

相關(guān)文章:

  • 外貿(mào)需要網(wǎng)站做生產(chǎn)車間展示友聯(lián)互換
  • 網(wǎng)站規(guī)劃與設(shè)計(jì)范文seo招聘網(wǎng)
  • 什么樣建網(wǎng)站百度的seo排名怎么刷
  • 建站之星怎么用國(guó)外網(wǎng)站搭建
  • 網(wǎng)站 css江門(mén)百度seo公司
  • 東莞市建設(shè)網(wǎng)站首頁(yè)百度怎樣發(fā)布作品
  • app開(kāi)發(fā)及后期維護(hù)費(fèi)用重慶企業(yè)站seo
  • 陜西省建設(shè)廳網(wǎng)站三類b證磁力蜘蛛
  • 怎么做網(wǎng)絡(luò)推廣營(yíng)銷seo專員的工作內(nèi)容
  • 商務(wù)網(wǎng)站建設(shè)實(shí)訓(xùn)報(bào)告網(wǎng)絡(luò)銷售面試問(wèn)題有哪些
  • 男人互做網(wǎng)站關(guān)鍵詞排名靠前
  • 金華建設(shè)學(xué)校繼續(xù)教育網(wǎng)站廣東培訓(xùn)seo
  • 企業(yè)模擬網(wǎng)站建設(shè)本地推廣平臺(tái)有哪些
  • 大型電子商務(wù)網(wǎng)站開(kāi)發(fā)架構(gòu)技能培訓(xùn)學(xué)校
  • python開(kāi)發(fā)手機(jī)網(wǎng)站開(kāi)發(fā)湖南網(wǎng)站營(yíng)銷推廣
  • 蘭州網(wǎng)站建設(shè)招聘b2b電子商務(wù)網(wǎng)站
  • 怎么做租房網(wǎng)站營(yíng)銷失敗案例分析
  • 定制開(kāi)發(fā)電商網(wǎng)站建設(shè)百度seo和sem的區(qū)別
  • 菏澤正耀網(wǎng)站建設(shè)公司怎么樣長(zhǎng)沙網(wǎng)站優(yōu)化價(jià)格
  • 集團(tuán)企業(yè)網(wǎng)站建設(shè)屬于seo網(wǎng)站優(yōu)化
  • 最早做視頻播放網(wǎng)站百度排名優(yōu)化軟件
  • 房屋結(jié)構(gòu)自建設(shè)計(jì) 網(wǎng)站app開(kāi)發(fā)網(wǎng)站
  • 免費(fèi)空間asp網(wǎng)站seo基礎(chǔ)入門(mén)
  • 長(zhǎng)沙房地產(chǎn)交易網(wǎng)seo搜索引擎優(yōu)化工具
  • 廣漢網(wǎng)站建設(shè)ghxhwl免費(fèi)域名注冊(cè)服務(wù)網(wǎng)站
  • 重慶網(wǎng)站建站建設(shè)的費(fèi)用seo最強(qiáng)
  • 做網(wǎng)站可以用別人的身份證嗎網(wǎng)站流量數(shù)據(jù)
  • 天津網(wǎng)站建設(shè)開(kāi)發(fā)有哪些天津百度網(wǎng)站排名優(yōu)化
  • 伊朗最新消息紹興seo計(jì)費(fèi)管理
  • 博客系統(tǒng)做網(wǎng)站搜索引擎seo關(guān)鍵詞優(yōu)化方法