您可以創建設備模型並使用其屬性來了解應用程序是否在手機上運行。請參閱以下鏈接:
https://help.sap.com/saphelp_uiaddon10/helpdata/en/32/5b8edafcfa4c9c8fbd42455a60e379/content.htm
編輯:
方法1:如果您的設備模型成立,那麼你就可以在你的代碼中使用它: 在Component.js:
var deviceModel = new sap.ui.model.json.JSONModel({
isTouch : sap.ui.Device.support.touch,
isNoTouch : !sap.ui.Device.support.touch,
isPhone : sap.ui.Device.system.phone,
isNoPhone : !sap.ui.Device.system.phone,
listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",
listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"
});
deviceModel.setDefaultBindingMode("OneWay");
this.setModel(deviceModel, "device");
如果喲
sap.ui.Device.system.phone
值:
在XML:
<Dialog id="confirmDialog"
title="Confirm"
showHeader="true"
state="Warning"
stretch="{device>/isPhone}"
type="Standard">
方式二:您可以隨時使用你不想創建一個單獨的模型。但是,我建議您創建一個設備模型並使用它。
<Dialog id="confirmDialog"
title="Confirm"
showHeader="true"
state="Warning"
stretch="sap.ui.Device.system.phone"
type="Standard">