"Uncaught TypeError: sap.ui.require.toUrl is not a function"
"Uncaught TypeError: sap.ui.require.toUrl is not a function"
我尝试学习 Fiori 时出现错误。任何帮助将不胜感激。
在onInit
中说:
Uncaught TypeError: sap.ui.require.toUrl is not a function.
sap.ui.define([
"sap/ui/core/mvc/Controller",
// ...
], function(Controller /*...*/) {
"use strict";
return Controller.extend("Upload_TestUpload_Test.controller.View1", {
onInit: function() {
var sPath = sap.ui.require.toUrl("Upload_Test/uploadCollection.json");
this.getView().setModel(new JSONModel(sPath));
},
// ...
});
});
Sap UI 版本:“1.52.12”
var sPath = sap.ui.require.toUrl("Upload_Test/uploadCollection.json");
Sap UI Version : "1.52.12"
API sap.ui.require.toUrl
仅从 1.58.0 开始可用。如果无法更新 UI5,则必须使用 API jQuery.sap.getResourcePath
代替:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"jquery.sap.global",
// ...
], function(Controller, jQuery /*...*/) {
"use strict";
return Controller.extend("...", {
onInit: function() {
var sPath = jQuery.sap.getResourcePath("Upload_Test/uploadCollection.json"); // Use sap.ui.require.toUrl from UI5 1.58. The jQuery API is deprecated!
this.getView().setModel(new JSONModel(sPath));
// ...
},
// ...
});
});
我尝试学习 Fiori 时出现错误。任何帮助将不胜感激。
在onInit
中说:
Uncaught TypeError: sap.ui.require.toUrl is not a function.
sap.ui.define([
"sap/ui/core/mvc/Controller",
// ...
], function(Controller /*...*/) {
"use strict";
return Controller.extend("Upload_TestUpload_Test.controller.View1", {
onInit: function() {
var sPath = sap.ui.require.toUrl("Upload_Test/uploadCollection.json");
this.getView().setModel(new JSONModel(sPath));
},
// ...
});
});
Sap UI 版本:“1.52.12”
var sPath = sap.ui.require.toUrl("Upload_Test/uploadCollection.json");
Sap UI Version : "1.52.12"
API sap.ui.require.toUrl
仅从 1.58.0 开始可用。如果无法更新 UI5,则必须使用 API jQuery.sap.getResourcePath
代替:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"jquery.sap.global",
// ...
], function(Controller, jQuery /*...*/) {
"use strict";
return Controller.extend("...", {
onInit: function() {
var sPath = jQuery.sap.getResourcePath("Upload_Test/uploadCollection.json"); // Use sap.ui.require.toUrl from UI5 1.58. The jQuery API is deprecated!
this.getView().setModel(new JSONModel(sPath));
// ...
},
// ...
});
});