SAPUI5自定义控件库主题

时间:2019-01-15 09:19:27

标签: sapui5

我最近创建了一个SAPUI5库,其中包含许多可重复使用的自定义控件,但我找不到一种方法来制作包含该库的应用程序,并加载.less主题文件,正在定义自定义控件样式。

所以基本上,我想做的是使库将自定义控件样式嵌入到其他应用程序中。

这里是manifest.json

{
"_version": "1.7.0",

"sap.app": {
    "id": "zproject",
    "type": "library",
    "embeds": [],
    "i18n": "messagebundle.properties",
    "applicationVersion": {
        "version": "1.0.0"
    },
    "title": "{{title}}",
    "description": "{{description}}",
    "ach": "",
    "resources": "resources.json",
    "offline": false
},
"sap.ui": {
    "technology": "UI5",
    "deviceTypes": {
        "desktop": true,
        "tablet": true,
        "phone": false
    },
    "supportedThemes": [
        "sap_hcb",
        "sap_belize",
        "sap_belize_plus"

    ]
},

"sap.ui5": {
    "dependencies": {
        "minUI5Version": "1.30.0",
        "libs": {
            "sap.ui.core": {
                "minUI5Version": "1.30.0"
            }
        }
    },
    "contentDensities": {
        "compact": true,
        "cozy": false
    }
},

"sap.platform.hcp": {
    "uri": ""
},

"sap.fiori": {
    "registrationIds": [],
    "archeType": "reusecomponent"
}

这是我的文件夹结构:

enter image description here

我可以为您提供更多您需要的信息,但我认为这些是最有用的

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,最后我在SAPUI5的api文档中找到了答案:sap.ui.getCore().initLibrary

在我的情况下,属性noLibraryCSS设置为true,这意味着未加载任何主题。请仔细检查library.js并将此属性设置为false-或完全删除它,因为默认值为false

答案 1 :(得分:0)

好的,所以我仍然不知道为什么主题没有直接加载它,但是我发现了两种制作方法:

  • sa.ui.dom.includeStylesheet()方法可直接在组件中使用,以按组件CSS Documentation here

  • 加载
  • 在包含库的应用程序中添加资源(一旦部署了库应用程序,它将在.less文件中将library.css文件构建为manifest.json文件):

        "resources": {
        "css": [{
            "uri": "css/style.css"
        }, {
            "uri": "/resources/YOURLIBRARY/themes/base/library.css" 
        }]
    },
    
相关问题