首页 > 解决方案 > 显示联系人页面后框架数组为空,下一个“tns-template-drawer-navigation-ts”导航抛出异常

问题描述

在使用 nativescript-contacts 插件后导航到另一个页面时遇到问题(异常)。该应用程序是使用 tns-template-drawer-navigation-ts 模板构建的。一切正常,直到我访问手机的联系人并返回,然后尝试使用抽屉导航切换到另一个页面。问题是在我从联系人屏幕返回并且 topmost().navigate 函数调用 Frame 后,Frame 堆栈为空,并且由于 Frame 堆栈为空(数组长度 = 0),因此返回“未定义”。以下是 Chrome 调试器中代码的相关部分。这是一个核心、插件错误还是我应该在调用 getContact 之前或之后在堆栈上推送一个框架。

我已经更新到 tns 5.3.1,更新了 tns 并尝试在我自己的代码中解决问题,但代码在核心 nativescript 中失败。

我的代码:

export function onGetContact(args: EventData) {
    Permissions.requestPermissions([android.Manifest.permission.GET_ACCOUNTS,
    android.Manifest.permission.READ_CONTACTS,],
        "Permission to access your contacts is requested")
        .then(() => {
            Contacts.getContact()
                .then((args: GetContactResult) => {
                    /// Returns args:
                    /// args.reponse: "fetch"
                    /// args.data: Generic cross platform JSON object, null if no contacts were found.
                    logContact(args);
                    storeContact(args.data);

                }, function (err) {
                    console.log("Error: " + err);
                })
        });
}

联系人返回正常,当前页面有效。当我尝试使用抽屉式水龙头导航离开当前页面时会出现此问题,该抽屉式水龙头应将我带到我的其他页面之一。所以看起来“联系人”显示正在清除帧数组(帧堆栈)。

标签: nativescriptnativescript-plugin

解决方案


好的,Nikolay Tsonev 给了我答案,这是我的错,在开发选项中启用了“不保留活动选项”。禁用它后,当我在应用程序之间切换时一切正常。


推荐阅读