GoBack按钮[UWP] [WINJS] [英] GoBack Button [UWP][WINJS]

查看:72
本文介绍了GoBack按钮[UWP] [WINJS]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我想长时间在我的Windows 10应用程序上运行GoBack按钮。我是初学者,有了它,但无法解决它,似乎无法正常工作。有人可以发布Step-By-Step教程如何使用WINJS在UWP应用程序的标题栏中添加GoBack按钮吗?我试了很多,
i找到了一些脚本,比如:

Hello,
i'm trying for long time to get a GoBack button working on my Windows 10 App. I'm beginner, with it, but can't fix it, it seems not working. Can someone post a Step-By-Step tutorial how to add a GoBack button in titlebar for UWP app using WINJS? I tried a lot, i found some scripts, like:

var currentview = Windows.UI.Core.SystemNavigationManager.getForCurrentView();

currentview.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible;

currentview.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible;




$
是的,它是可见,但我不能回去。我不知道在哪里放一个代码,回去。我创建了一个Goback.js,看起来像:



Yes, it's visible, but i can't go back. I don't know where to put a code, to go Back. I Created a Goback.js, it looks like:

(function () {
        "use strict";
    
        var currentview = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
        currentview.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible;
    
        function onBackRequested(eventArgs) {
            Wwindow.history.back(-1);
            systemNavigationManager.removeEventListener("backrequested", onBackRequested);
        }  
    })();




$
但似乎无效。有人可以提供帮助吗?$


谢谢。



But it seems not working. Can someone help`?

Thanks.

推荐答案

你好,我我不确定Wwindow是什么,我猜它只是一个WinJS.Navigation变量,但WinJS.Navigation.history中没有返回函数这样的东西。但是,WinJS.Navigation命名空间中有一个后退函数,你可以通过传入你想要返回的页面来使用
。如果要返回1页,则必须将参数设置为1而不是-1。但是,如果你想继续,你可以通过在同一命名空间中使用forward函数来实现。

Hello, I'm not sure what Wwindow is, I'm guessing that it's just a WinJS.Navigation variable, but there is no such thing as a back function inside WinJS.Navigation.history. However, there is a back function inside the WinJS.Navigation namespace, which you can use by passing in the number of pages you want to go back. If you want to go back 1 page, you have to set the argument to 1 and not -1. However, if you want to go forward, you can do so by using the forward function in the same namespace.

WinJS.Navigation.back(1).done( /* Your success and error handlers */ );

您还必须在当前视图中收听重新请求的事件,而不是在SystemNavigationManager本身内部。

You also have to listen to the backrequested event inside the current view, and not inside the SystemNavigationManager itself.

例如:

            currentview.addEventListener("backrequested", function () {
                WinJS.Navigation.back(1).done( /* Your success and error handlers */);
            });

您还应该查看navigator.js文件,该文件是Windows 8.1导航模板的一部分。它基本上可以为您完成所有工作。它在Windows 10应用程序中运行得非常好。你可以在这里找到这个文件:New Project> JavaScript> Windows
8> Windows>导航应用; navigator.js文件位于js文件夹中。

You should also check out the navigator.js file, which is part of the Windows 8.1 navigation template. It basically does all the work for you. And it works perfectly fine in Windows 10 apps. You can find the file here: New Project > JavaScript > Windows 8 > Windows > Navigation-App; The navigator.js file is inside js folder.

链接:

https:// msdn .microsoft.com / zh-CN / library / windows / apps / br229802.aspx?f = 255& MSPPError = -2147217396

https://msdn.microsoft.com/en-us/library/windows/apps/br229802.aspx?f=255&MSPPError=-2147217396

https://msdn.microsoft.com/de- de / library / windows / apps / windows.ui.core.systemnavigationmanager.backrequested?f = 255& MSPPError = -2147217396

https://msdn.microsoft.com/de-de/library/windows/apps/windows.ui.core.systemnavigationmanager.backrequested?f=255&MSPPError=-2147217396


这篇关于GoBack按钮[UWP] [WINJS]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆