SAPUI5 获取当前屏幕尺寸
SAPUI5 get the current screen size
在我的应用程序的特定点,我需要确定当前 screen size(台式机或平板电脑)。至少我需要屏幕宽度,但 sap.m.ScreenSize 会更好。
我该怎么做?提前致谢!
function sizeChanged(mParams) {
switch(mParams.name) {
case "Phone":
// Do what is needed for a little screen
break;
case "Tablet":
// Do what is needed for a medium sized screen
break;
case "Desktop":
// Do what is needed for a large screen
}
}
// Register an event handler to changes of the screen size
sap.ui.Device.media.attachHandler(sizeChanged, null,
sap.ui.Device.media.RANGESETS.SAP_STANDARD);
// Do some initialization work based on the current size
sizeChanged(sap.ui.Device.media.getCurrentRange(sap.ui.Device.media.RANGESETS.SAP_STANDARD));
我从以下位置获得此代码:
https://sapui5.hana.ondemand.com/1.54.8/#/api/sap.ui.Device.media
在那里您还将获得有关其工作原理的更详细说明
在我的应用程序的特定点,我需要确定当前 screen size(台式机或平板电脑)。至少我需要屏幕宽度,但 sap.m.ScreenSize 会更好。
我该怎么做?提前致谢!
function sizeChanged(mParams) {
switch(mParams.name) {
case "Phone":
// Do what is needed for a little screen
break;
case "Tablet":
// Do what is needed for a medium sized screen
break;
case "Desktop":
// Do what is needed for a large screen
}
}
// Register an event handler to changes of the screen size
sap.ui.Device.media.attachHandler(sizeChanged, null,
sap.ui.Device.media.RANGESETS.SAP_STANDARD);
// Do some initialization work based on the current size
sizeChanged(sap.ui.Device.media.getCurrentRange(sap.ui.Device.media.RANGESETS.SAP_STANDARD));
我从以下位置获得此代码:
https://sapui5.hana.ondemand.com/1.54.8/#/api/sap.ui.Device.media
在那里您还将获得有关其工作原理的更详细说明