Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nativescript 迁移到v7的应用程序现在在iOS模拟器上启动时出现以下错误:无法读取属性';主屏幕';未定义的_Nativescript - Fatal编程技术网

Nativescript 迁移到v7的应用程序现在在iOS模拟器上启动时出现以下错误:无法读取属性';主屏幕';未定义的

Nativescript 迁移到v7的应用程序现在在iOS模拟器上启动时出现以下错误:无法读取属性';主屏幕';未定义的,nativescript,Nativescript,我刚刚将工具更新到v7并迁移了应用程序。 现在,当我在emulator上运行时,我得到了未捕获的TypeError:无法读取未定义的属性“mainScreen” 我构造了常数: const screen = require("tns-core-modules/platform").screen; 并称之为正常: screenWidth: screen.mainScreen.widthDIPS, 但自动完成将无法识别.mainScreen属性 我做错了什么?在Natives

我刚刚将工具更新到v7并迁移了应用程序。 现在,当我在emulator上运行时,我得到了未捕获的TypeError:无法读取未定义的属性“mainScreen”

我构造了常数:

const screen = require("tns-core-modules/platform").screen;
并称之为正常:

screenWidth: screen.mainScreen.widthDIPS,
但自动完成将无法识别.mainScreen属性


我做错了什么?

在Nativescript 7中,所有模块都以
@Nativescript/…
范围开始

screen
war重命名为
screen

您必须使用新的导入和命名

const screen = require("@nativescript/core/platform").Screen;

const screenWidth = Screen.mainScreen.widthDIPs;

我搜索了几个小时才找到这个…非常感谢!!!官方网页上没有任何提示