为什么后退按钮在毛伊岛被隐藏?

Tho*_*ton 4 maui

我有一个带有页面 A 和页面 B 的 .Net MAUI 应用程序。

我想从页面 A >>> 页面 B 移至页​​面。

当我使用以下代码移动时,我有一个后退按钮(这是我的情况下所需的行为):

await Navigation.PushAsync(new MyPage());
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用以下代码移动到其他页面,则没有后退按钮:

await Shell.Current.GoToAsync("//MyPage");
Run Code Online (Sandbox Code Playgroud)

由于其他一些原因,我需要通过 Shell 使用导航。

为什么使用 Shell 导航时没有后退按钮?

Tho*_*ton 6

答案如下:

代替

await Shell.Current.GoToAsync("//MyPage");
Run Code Online (Sandbox Code Playgroud)

我应该做

await Shell.Current.GoToAsync("/MyPage");
Run Code Online (Sandbox Code Playgroud)

原因 :

根据这里的官方文档:

route : The route hierarchy will be searched for the specified route, upwards from the current position. The matching page will be pushed to the navigation stack.
/route : The route hierarchy will be searched from the specified route, downwards from the current position. The matching page will be pushed to the navigation stack.
//route : The route hierarchy will be searched for the specified route, upwards from the current position. The matching page will replace the navigation stack.
///route : The route hierarchy will be searched for the specified route, downwards from the current position. The matching page will replace the navigation stack.
Run Code Online (Sandbox Code Playgroud)