国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

做外貿網站需要什么卡西安網站快速排名提升

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

簡言

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

要想詳細了解 React Navigation 的具體用法,請訪問其React Navigation官網。

本篇是在window系統android環(huán)境下使用,mac系統請查看官網。

React Navigation

安裝

官網安裝指南Doc
核心包安裝命令:

yarn add @react-navigation/native

除此之外,還要安裝:

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

react-native-screens 軟件包需要一個額外的配置步驟才能在安卓設備上正常運行。編輯位于 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);}// ...
}

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

import android.os.Bundle;

在這里插入圖片描述

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

使用

我們需要用 NavigationContainer 封裝整個應用程序。通常,您會在入口文件(如 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>);
}

現在就可以正常運行了。

navigator

導航器 ,上面我們只是安裝了React Navigation基礎,并沒有真正使用導航功能。
實現導航功能需要安裝對應的navigator 才可以。
6.x版本的navigator 有以下幾種:
在這里插入圖片描述

Stack Navigator 堆棧導航器

堆棧導航器為您的應用程序提供了一種在屏幕間轉換的方法,每個新屏幕都被放置在堆棧的頂部。
這種導航器和web的history stack比較相像。

雖然 @react-navigation/stack 可定制性極強,但它是用 JavaScript 實現的。雖然它可以使用本機運行動畫和手勢,但性能可能不如本機實現的快。

安裝:

yarn add @react-navigation/stack

然后,需要安裝和配置堆棧導航器所需的庫:

yarn add react-native-gesture-handler

要最終完成 react-native-gesture-handler 的安裝,請在入口文件(如 index.js 或 App.js)的頂部添加以下內容(確保它位于頂部,且之前沒有其他內容)

import 'react-native-gesture-handler';

例子:

import { createStackNavigator } from '@react-navigation/stack';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內容Feed</Text>;
}
function Settings() {return <Text>top內容Settings</Text>;
}
function Profile() {return <Text>top內容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 原生堆棧導航器

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

雖然 @react-navigation/native-stack 提供了原生性能并暴露了原生功能,如 iOS 上的大標題等,但它可能不如 @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內容Feed</Text>;
}
function Settings() {return <Text>top內容Settings</Text>;
}
function Profile() {return <Text>top內容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 抽屜導航器

抽屜導航器在屏幕一側顯示一個導航抽屜,可通過手勢打開或關閉。
在這里插入圖片描述
安裝:

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

要最終完成 react-native-gesture-handler 的安裝,請在入口文件(如 index.js 或 App.js)的頂部(確保位于頂部,且之前沒有其他內容)添加以下內容

import 'react-native-gesture-handler';

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

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

不加在編譯時會報react-native-reanimated相關的錯誤。

例子:

import { createDrawerNavigator } from '@react-navigation/drawer';
import {Text,
} from 'react-native';
function Feed() {return <Text>top內容Feed</Text>;
}
function Notifications() {return <Text>top內容Notifications</Text>;
}
function Profile() {return <Text>top內容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導航器

屏幕底部有一個簡單的標簽欄,讓你能在不同路線之間切換。路由是懶散初始化的,只有在首次聚焦時才會安裝其屏幕組件。
安裝:

yarn add @react-navigation/bottom-tabs

例子:

例子使用了react-native-vector-icons 圖標庫,使用前記得下載安裝安裝參考

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內容Feed</Text>;
}
function Notifications() {return <Text>top內容Notifications</Text>;
}
function Profile() {return <Text>top內容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風格的底部標簽導航器。
官網參考指南

Material Top Tabs Navigator

頂部標簽導航器
安裝:

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內容Feed</Text>;
}
function Notifications() {return <Text>top內容Notifications</Text>;
}
function Profile() {return <Text>top內容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>);
}

效果

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

結語

這幾種navigator 可以隨意嵌套使用,具體使用方法請到官方網站閱覽。

http://m.aloenet.com.cn/news/33433.html

相關文章:

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