按照以下指南尝试为我的项目设置深层链接:https://reactnavigation.org/docs/en/next/deep-linking.html
但是,在尝试实施时,我总是看到主屏幕而不是帐户屏幕。
运行这样的示例:
adb shell am start -W -a android.intent.action.VIEW -d "hdsmobileapp://main/account/" com.digithurst.hdsapp
我有一个嵌套的导航,可以在下面看到:
import {createDrawerNavigator, createStackNavigator} from "react-navigation";
import {NavigationOptions} from "./components/NavigationOptions";
import {SideMenu} from "./components/SideMenu";
import LoginScreen from "./containers/LoginScreen";
import MainScreen from "./containers/MainScreen";
import MyAccountScreen from "./containers/MyAccountScreen";
import SplashScreen from "./containers/SplashScreen";
import { createAppContainer} from "react-navigation";
const AppContainer = createAppContainer(
{
Splash: {
screen: SplashScreen,
navigationOptions: {
header: null,
},
},
Login: {
screen: createStackNavigator(
{
Login: {
screen: LoginScreen,
navigationOptions: {
header: null,
},
},
},
)
},
Main: {
screen: createDrawerNavigator(
{
Main: {
screen: createStackNavigator(
{
Main: {
screen: MainScreen,
navigationOptions: NavigationOptions.getSearchFilterHeader("title.main"),
},
MyAccount: { screen: MyAccountScreen, path: 'account',},
},
),
},
}, {
drawerWidth: 300,
initialRouteName: "Main",
contentComponent: SideMenu,
},
),
},
},
);
然后在App.tsx中包含以下内容:
import React, {Component} from "react";
import SplashScreen from "react-native-splash-screen";
import {Provider} from "react-redux";
import RootStack from "./navigation";
import AppContainer from "./navigation";
import store from "./store/store";
import {createAppContainer} from 'react-navigation'
import { AppRegistry } from 'react-native';
class App extends Component {
public componentDidMount() {
SplashScreen.hide();
}
public render() {
return (
<Provider store={store}>
<RootStack uriPrefix={prefix} />
</Provider>
);
}
}
const prefix = 'hdsmobileapp://hdsmobileapp';
const MainApp = () => <AppContainer uriPrefix={prefix} />;
AppRegistry.registerComponent('App', () => MainApp);
export default App;
我在这里明显缺少什么吗?
答案 0 :(得分:0)
您在导航声明中未指定要提供的网址(func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return groupedEventsArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "PopularCell", for: indexPath)
let (category, events) = self.groupedEventsArr[indexPath.row]
print("Category: \(category)")
events.forEach {
print("Event Name:\($0.event_name)")
}
return cell
}
的{{1}}部分。
您应该将其添加到public async Task<bool> Create(RequestDTOCreateUser userDTO)
{
//Create user
var userDomain = _mapper.Map<RequestDTOCreateUser, UserDomain>(userDTO);
//Push to database
_unitOfWork.Complete();
//Add to log [CAN I MAKE THIS ASYNC AND NEVER WAIT FOR IT?]
_log.Add(userDomain, "User created" });
//Response
return true;
}
道具中,或者在尝试到达main
位置时避免使其通过。
hdsmobileapp://main/account/
答案 1 :(得分:0)
您尚未将path
道具添加到父级导航器中。文档特别提到,当嵌套导航器时,必须提供path
属性。
如果我们有嵌套的导航器,则需要为每个父屏幕提供一个路径。所有路径都将串联起来,也可以是一个空字符串。
只要您不想将导航器添加到路径,只需传递''null字符串。
像这样更改路由器配置,以使路径hdsmobileapp://main/account/
正常工作,
const AppContainer = createAppContainer(
{
Splash: {
screen: SplashScreen,
navigationOptions: {
header: null,
},
},
Login: {
screen: createStackNavigator(
{
Login: {
screen: LoginScreen,
navigationOptions: {
header: null,
},
},
},
)
},
MainDrawer: {
screen: createDrawerNavigator(
{
MainStack: {
screen: createStackNavigator(
{
Main: {
screen: MainScreen,
navigationOptions: NavigationOptions.getSearchFilterHeader("title.main"),
},
MyAccount: { screen: MyAccountScreen, path: 'account',},
},
),
path:'main'
},
}, {
drawerWidth: 300,
initialRouteName: "Main",
contentComponent: SideMenu,
},
),
path: '',
},
},
);
还可以考虑重命名父级导航器,因为当您添加更多屏幕和导航时,它将导致错误。
最新的深层链接文档here