From 014269b798f50259332b6660dbdfd76c73b7630f Mon Sep 17 00:00:00 2001 From: tourze Date: Mon, 15 Jul 2019 19:08:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9=E9=A1=B5=E9=9D=A2=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=9C=A8RN=E7=8E=AF=E5=A2=83=E8=83=BD=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89navigationOptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RN上面对导航的要求更加灵活。 参考:https://reactnavigation.org/docs/en/header-buttons.html --- packages/taro-router-rn/src/getWrappedScreen.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/taro-router-rn/src/getWrappedScreen.js b/packages/taro-router-rn/src/getWrappedScreen.js index 0a1a87d3eb0f..47c5abdcb9ab 100644 --- a/packages/taro-router-rn/src/getWrappedScreen.js +++ b/packages/taro-router-rn/src/getWrappedScreen.js @@ -25,7 +25,7 @@ function getWrappedScreen (Screen, Taro, globalNavigationOptions = {}) { const title = navigation.getParam('title') || navigationOptions.title || globalNavigationOptions.title const rest = (navigationOptions.navigationStyle || globalNavigationOptions.navigationStyle) === 'custom' ? {header: null} : {} const headerTintColor = navigation.getParam('headerTintColor') || navigationOptions.headerTintColor || globalNavigationOptions.headerTintColor - return { + const options = { ...rest, headerTitle: {navigation.getParam('isNavigationBarLoadingShow') && } @@ -36,6 +36,15 @@ function getWrappedScreen (Screen, Taro, globalNavigationOptions = {}) { backgroundColor: navigation.getParam('backgroundColor') || navigationOptions.backgroundColor || globalNavigationOptions.backgroundColor } } + + // 如果页面组件也定义了navigationOptions,那么就合并页面那边的返回值 + if (Screen.navigationOptions !== undefined) { + const target = Screen.navigationOptions({ navigation }); + Object.assign(target, options); + return target; + } + return options; + } } /**