最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

react-navigation之動(dòng)態(tài)修改title的內(nèi)容

 更新時(shí)間:2018年09月26日 13:45:04   作者:別說(shuō)你還沒(méi)有盡力  
這篇文章主要介紹了react-navigation之動(dòng)態(tài)修改title的內(nèi)容,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

本文介紹了react-navigation之動(dòng)態(tài)修改title的內(nèi)容,分享給大家,具體如下:

效果圖:


動(dòng)態(tài)修改title內(nèi)容:

 static navigationOptions = {
    title: ({ state }) => `Chat with ${state.params.user}`
  };

ps:`Chat with ${state.params.user}` 這里有個(gè)注意的地方,是這個(gè)符號(hào)·而不是單引號(hào)‘

index.android.js

/** 
* Sample React Native App 
* https://github.com/facebook/react-native 
* @flow
 */
import {
  AppRegistry,
}from 'react-native';
import rootApp from './js/rootApp'
AppRegistry.registerComponent('GankProject', () = >rootApp);

rootApp.js:

/**
 * Created by Administrator on 2017/3/31 0031. 
*/
'use strict'import React from 'react';
import {
  AppRegistry,
  Text,
  View,
  Button,
}
from 'react-native';
import {
  StackNavigator
}
from 'react-navigation';
import ChatScreen from './ChatScreen';
class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Welcome',
    //設(shè)置標(biāo)題內(nèi)容  };  
    render() {
      const {
        navigate
      } = this.props.navigation;
      return ( < View > <Text > Hello, Navigation ! </Text>   
      <Button      
    onPress={() => navigate('Chat',{user:'Lucy'})}       
    title="Chat with Lucy"/ > </View> 
   ); 
 }
} 
const SimpleApp = StackNavigator(
{  
 Home: {screen: HomeScreen}, 
  Chat:{screen:ChatScreen}, 
}
); 
export default SimpleApp;

ChatScreen.js:

/**
 * Created by Administrator on 2017/3/31 0031. 
*/
'use strict'
import React,{Component}from 'react';
import {View,Text}from 'react-native';
class ChatScreen extends Component {
  static navigationOptions = {
    title: ({state}) = >`Chat with $ {state.params.user}`
  };
  render() {
    const {params} = this.props.navigation.state;
    return ( < View > <Text > Chat with {
      params.user
    } < /Text>      </View > );
  }
}
export default ChatScreen;

效果2:


/** * Created by Administrator on 2017/3/31 0031. */
'use strict'
import React, { Component}from 'react';
import {View, Text, Button}from 'react-native';
class ChatScreen extends Component {
  static navigationOptions = {
    title: ({
        state
      }) => {
        if (state.params.mode === 'info') {
          return `${state.params.user}'s Contact Info`;
        }
        return `Chat with ${state.params.user}`;
      },
      header: ({state, setParams}) => {
        // The navigation prop has functions like setParams, goBack, and navigate.  
        let right = ( < Button title = {
            `${state.params.user}'s info`
          }
          onPress = {
            () => setParams({
              mode: 'info'
            })
          }
          />     
          );     
   if (state.params.mode === 'info') {    
   right = (      
   <Button          
   title="Done"           
   onPress={() => setParams({ mode: 'none' })}        
   / >
        );
      }
    return {right};
  },
};
render() {
  const {
    params
  } = this.props.navigation.state;
  return ( 
    < View >
    < Text > Chat with {params.user} < /Text> 
    </View >
  );
}
}
export default ChatScreen;

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • React Native仿美團(tuán)下拉菜單的實(shí)例代碼

    React Native仿美團(tuán)下拉菜單的實(shí)例代碼

    本篇文章主要介紹了React Native仿美團(tuán)下拉菜單的實(shí)例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-08-08
  • 淺談React?Refs?使用場(chǎng)景及核心要點(diǎn)

    淺談React?Refs?使用場(chǎng)景及核心要點(diǎn)

    本文主要介紹了React?Refs?使用場(chǎng)景及核心要點(diǎn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • React視頻播放控制組件Video Controls的實(shí)現(xiàn)

    React視頻播放控制組件Video Controls的實(shí)現(xiàn)

    本文主要介紹了React視頻播放控制組件Video Controls的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2025-02-02
  • TypeScript在React項(xiàng)目中的使用實(shí)踐總結(jié)

    TypeScript在React項(xiàng)目中的使用實(shí)踐總結(jié)

    這篇文章主要介紹了TypeScript在React項(xiàng)目中的使用總結(jié),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-04-04
  • React實(shí)現(xiàn)一個(gè)支持動(dòng)態(tài)插槽的Layout組件

    React實(shí)現(xiàn)一個(gè)支持動(dòng)態(tài)插槽的Layout組件

    這篇文章主要為大家詳細(xì)介紹了如何使用React實(shí)現(xiàn)一個(gè)支持動(dòng)態(tài)注冊(cè)內(nèi)容的插槽組件,文中的示例代碼簡(jiǎn)潔易懂,有需要的小伙伴可以了解一下
    2025-02-02
  • react在安卓中輸入框被手機(jī)鍵盤(pán)遮擋問(wèn)題的解決方法

    react在安卓中輸入框被手機(jī)鍵盤(pán)遮擋問(wèn)題的解決方法

    這篇文章主要給大家介紹了關(guān)于react在安卓中輸入框被手機(jī)鍵盤(pán)遮擋問(wèn)題的解決方法,文中通過(guò)圖文以及示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧
    2018-09-09
  • react用Redux中央倉(cāng)庫(kù)實(shí)現(xiàn)一個(gè)todolist

    react用Redux中央倉(cāng)庫(kù)實(shí)現(xiàn)一個(gè)todolist

    這篇文章主要為大家詳細(xì)介紹了react用Redux中央倉(cāng)庫(kù)實(shí)現(xiàn)一個(gè)todolist,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-09-09
  • react國(guó)際化化插件react-i18n-auto使用詳解

    react國(guó)際化化插件react-i18n-auto使用詳解

    這篇文章主要介紹了react國(guó)際化化插件react-i18n-auto使用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-03-03
  • windows下create-react-app 升級(jí)至3.3.1版本踩坑記

    windows下create-react-app 升級(jí)至3.3.1版本踩坑記

    這篇文章主要介紹了windows下create-react-app 升級(jí)至3.3.1版本踩坑記,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • React深入分析更新的創(chuàng)建源碼

    React深入分析更新的創(chuàng)建源碼

    React組件分為函數(shù)組件與class組件;函數(shù)組件是無(wú)狀態(tài)組件,class稱為類組件;函數(shù)組件只有props,沒(méi)有自己的私有數(shù)據(jù)和生命周期函數(shù);class組件有自己私有數(shù)據(jù)(this.state)和生命周期函數(shù)
    2023-01-01

最新評(píng)論

阆中市| 聂荣县| 岳普湖县| 韩城市| 涞源县| 北安市| 庆阳市| 民乐县| 视频| 景宁| 连云港市| 永和县| 南乐县| 阳东县| 玉山县| 商都县| 阿合奇县| 富阳市| 彰武县| 万州区| 长葛市| 巴里| 德州市| 海盐县| 大连市| 美姑县| 清镇市| 镇赉县| 邛崃市| 大新县| 定兴县| 望都县| 佛坪县| 夏邑县| 保山市| 镇江市| 合水县| 云南省| 南投市| 射洪县| 咸宁市|