Manifest 描述文件,通俗点就是对整个工程信息的描述
是和Component.JS 搭配使用
它里面包括 版本号,以及他的ID,多语言的加载路径等
那他是咋加载的呢?
记得之前的DEMO里全是把路由配置什么的直接写在component.js中,现在有了manifest,咱们就可以简洁component.js这个文件了
metadata:{
manifest:"json"
}
还有一种JS的加载方式,用不到,知道有这玩应就行。
{
"_version": "1.0.0",
"sap.app": {
"id": "ManifestDemoCase",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "ManifestDemoCase",
"description": "ManifestDemoCase",
"sourceTemplate": {
"id": "servicecatalog.connectivityComponent",
"version": "0.0.0"
},
"dataSources": {
//整个工程根服务路径的配置,比如我们可以配置ODAta、JSON数据
"mainService": {
//主服务
"uri": "/ODataDemoService/V2/(S(xogxg1ckcor00ikzn42t0sbk))/OData/OData.svc/",
//当前要访问的一个节点是在哪里
"type": "OData",
//当前这个URL是一个JSON格式还是一个OData格式
"settings": {
"odataVersion": "2.0"
//settings一般会设置OData的版本
}
},
"JSONService": {
"uri": "/ODataDemoService/V2/(S(xogxg1ckcor00ikzn42t0sbk))/OData/OData.svc/Suppliers?$format=json",
//变成JSON格式进行访问
"type": "json"
},
"OData.svc": {
"uri": "/ODataDemoService/V2/(S(xogxg1ckcor00ikzn42t0sbk))/OData/OData.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/OData.svc/metadata.xml"
}
}
},
"_version": "1.3.0"
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_belize"
],
"_version": "1.3.0"
},
"sap.ui5": {
"rootView": {
"viewName": "ManifestDemoCase.view.App",
"type": "XML"
},
//默认加载的根VIEW是哪一个
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {},
"sap.ushell": {},
"sap.collaboration": {},
"sap.ui.comp": {},
"sap.uxap": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "ManifestDemoCase.view",
"controlId": "myApp",
"controlAggregation": "pages",
"transition": "slide",
"bypassed": {
"target": "notFound"
}
},
"routes": [
{
"pattern": "",
"name": "",
"target": "First"
},
{
"pattern": "Second/{name}/{sex}/resume:?query:",
"name": "SecondView",
"target": "Second"
}
],
"targets": {
"First": {
"viewName": "First",
"viewLevel": 1
},
"Second": {
"viewName": "Second",
"viewLevel": 2
},
"notFound": {
"viewName": "NotFound",
"transition": "show"
}
}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "ManifestDemoCase.i18n.i18n"
}
},
//配置i18n的model
"": {
"type": "sap.ui.model.odata.v2.ODataModel",
//建议大家用odata.V2的版本
"settings": {
"defaultBindingMode": "TwoWay"
},
"dataSource": "mainService",
//为我们的ODataModel提供一个数据提供中心,上面定义过
"preload": true,
//在整个APP加载过程中,他要进行一个预加载
"async": true
//当前OData是一个异步模式
},
"MyModel": {
"type": "sap.ui.model.json.JSONModel",
"settings": {
"defaultBindingMode": "TwoWay"
},
"dataSource": "JSONService",
"preload": true
}
},
"resources": {
"css": [
{
"uri": "css/style.css"
}
]
},
"_version": "1.2.0"
}
}
然后我们在controller中调用
this.router = sap.ui.core.UIComponent.getRouterFor(this);
this.bundle = this.getOwnerComponent().getModel("i18n").getResourceBundle();
var oDataModel = this.getOwnerComponent().getModel();
var jsonModel = this.getOwnerComponent().getModel("MyModel");
最后有一个图形工具添加信息也不错,也很方便。