首页 > 解决方案 > 编译器错误 screen.mainScreen 是“屏幕”类型的静态成员

问题描述

帮助!。编译器返回错误

属性“mainScreen”是“Screen”类型的静态成员

我正在尝试获取 heightDIP,但是这个。

标签: nativescript

解决方案


您可能想检查Screen从哪里导入。过去我遇到过 VS Code 会自动导入错误的问题Screen

import { Screen } from '@nativescript/core';

// and the following should work
Screen.mainScreen.heightDIPs

推荐阅读