如何在 OpenUI5 中访问配置对象 Manifest.json
How to access config object in OpenUI5 Manifest.json
我正在使用 OpenUI5 框架创建自定义组件。我想访问我在组件的 manifest.json 文件中设置的一些配置设置。根据 documentation,我可以在嵌套在 "sap.ui5" 对象内的 "config" 对象中创建一些 name/value 对:
config: Static configuration; specify the name-value pairs that you need in your component.
而且我应该能够像这样从我的组件访问这些设置:
this.getMetadata().getManifest();
调用该方法并在控制台检查返回的 sap.ui5 对象后,唯一可用的对象是 "dependencies"、"extends"、"models" 和 "rootView" .没有 "config" 个对象。
如何在 manifest.json 中访问我的配置设置?
manifest.json 的片段:
...
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "ctg.openui5.components.webmap.view.Map",
"type": "HTML"
},
"dependencies": {
"minUI5Version": "1.30",
"libs": {
"sap.m": {}
}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "ctg.openui5.components.webmap.i18n.i18n"
}
}
},
"config": {
"lat": 1,
"lon": 2
}
}
基于documentation,您可以使用
this.getManifestEntry("/sap.ui5/config");
在您的组件中获取清单中的 config 对象。
我正在使用 OpenUI5 框架创建自定义组件。我想访问我在组件的 manifest.json 文件中设置的一些配置设置。根据 documentation,我可以在嵌套在 "sap.ui5" 对象内的 "config" 对象中创建一些 name/value 对:
config: Static configuration; specify the name-value pairs that you need in your component.
而且我应该能够像这样从我的组件访问这些设置:
this.getMetadata().getManifest();
调用该方法并在控制台检查返回的 sap.ui5 对象后,唯一可用的对象是 "dependencies"、"extends"、"models" 和 "rootView" .没有 "config" 个对象。
如何在 manifest.json 中访问我的配置设置?
manifest.json 的片段:
...
"sap.ui5": {
"_version": "1.1.0",
"rootView": {
"viewName": "ctg.openui5.components.webmap.view.Map",
"type": "HTML"
},
"dependencies": {
"minUI5Version": "1.30",
"libs": {
"sap.m": {}
}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "ctg.openui5.components.webmap.i18n.i18n"
}
}
},
"config": {
"lat": 1,
"lon": 2
}
}
基于documentation,您可以使用
this.getManifestEntry("/sap.ui5/config");
在您的组件中获取清单中的 config 对象。