Uncaught (in promise) SyntaxError: Unexpected token 'const' in UI5 (SAP)
Uncaught (in promise) SyntaxError: Unexpected token 'const' in UI5 (SAP)
嗨,我想在 Ui5 中进行 API 调用 ,但每次它都告诉我,它不知道是什么'Const'.
Uncaught SyntaxError: Unexpected token 'const'
The following error occurred while displaying routing target with name 'TargetResult': SyntaxError: Unexpected token 'const' -
Uncaught (in promise) SyntaxError: Unexpected token 'const'
我的Ui5通话:
sap.ui.define([
"sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
], function(Controller, JSONModel) {
"use strict";
return Controller.extend("TESTE.TESTE.controller.ResultDevice", {
onInit: function() {
var sUrl = "/api/tablets?limit=1000&offset=0";
const url = "https://jsonplaceholder.typicode.com/users";
fetch(url).then(res => res.json()).then(res => (
const dataModel = new JSONModel(); dataModel.setData({
items: res
}); this.getView().setModel(dataModel, "aribadevices")
)
},
},
您的花括号和圆括号有几个问题。这段代码应该可以工作,没有语法错误,并且每个表达式都在一个新行上更容易阅读。
sap.ui.define([
"sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
], function(Controller, JSONModel) {
"use strict";
return Controller.extend("TESTE.TESTE.controller.ResultDevice", {
onInit: function() {
var sUrl = "/api/tablets?limit=1000&offset=0";
const url = "https://jsonplaceholder.typicode.com/users";
fetch(url).then(res => res.json()).then(res => {
const dataModel = new JSONModel();
dataModel.setData({
items: res
});
this.getView().setModel(dataModel, "aribadevices");
})
}
})
});
嗨,我想在 Ui5 中进行 API 调用 ,但每次它都告诉我,它不知道是什么'Const'.
Uncaught SyntaxError: Unexpected token 'const' The following error occurred while displaying routing target with name 'TargetResult': SyntaxError: Unexpected token 'const' -
Uncaught (in promise) SyntaxError: Unexpected token 'const'
我的Ui5通话:
sap.ui.define([
"sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
], function(Controller, JSONModel) {
"use strict";
return Controller.extend("TESTE.TESTE.controller.ResultDevice", {
onInit: function() {
var sUrl = "/api/tablets?limit=1000&offset=0";
const url = "https://jsonplaceholder.typicode.com/users";
fetch(url).then(res => res.json()).then(res => (
const dataModel = new JSONModel(); dataModel.setData({
items: res
}); this.getView().setModel(dataModel, "aribadevices")
)
},
},
您的花括号和圆括号有几个问题。这段代码应该可以工作,没有语法错误,并且每个表达式都在一个新行上更容易阅读。
sap.ui.define([
"sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel"
], function(Controller, JSONModel) {
"use strict";
return Controller.extend("TESTE.TESTE.controller.ResultDevice", {
onInit: function() {
var sUrl = "/api/tablets?limit=1000&offset=0";
const url = "https://jsonplaceholder.typicode.com/users";
fetch(url).then(res => res.json()).then(res => {
const dataModel = new JSONModel();
dataModel.setData({
items: res
});
this.getView().setModel(dataModel, "aribadevices");
})
}
})
});