nativescript - 显示联系人页面后框架数组为空,下一个“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);
})
});
}
联系人返回正常,当前页面有效。当我尝试使用抽屉式水龙头导航离开当前页面时会出现此问题,该抽屉式水龙头应将我带到我的其他页面之一。所以看起来“联系人”显示正在清除帧数组(帧堆栈)。
解决方案
好的,Nikolay Tsonev 给了我答案,这是我的错,在开发选项中启用了“不保留活动选项”。禁用它后,当我在应用程序之间切换时一切正常。
推荐阅读
- youtube - YouTube Studio 多个摄像机角度
- python - 'python run.py' 在终端(mac)中不起作用。flask_restful 已安装。给出错误:'ModuleNotFoundError: No module named 'flask_restful''
- c++ - R 软件包安装给出了一个在这里声明的 `::std::isxdigit' 致命错误`
- python - Python SQLite3 数据库查询绑定错误
- javascript - 根据来自另一个选择的所选选项的值填充数据库中的选择元素
- ruby-on-rails-5 - 在 Rails 中以 PDF 格式渲染 js 生成的 SVG
- sql - 可以在 case 语句中嵌套更新语句吗?
- html - 如何正确引用 html 中的 javascript 文件?
- webview - TypeError:无法在 Nativescript 中读取未定义的属性“sdkVersion”
- scala - 隐式宏。默认隐式值。如何?