Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sapui5 SAP UI5组件开发元数据数据类型_Sapui5 - Fatal编程技术网

Sapui5 SAP UI5组件开发元数据数据类型

Sapui5 SAP UI5组件开发元数据数据类型,sapui5,Sapui5,我正在为UI5开发一个组件。在metadata->properties部分,我想定义一个Integer类型的属性。如果我通过“markerSize”设置数据类型:{type:“integer”,defaultValue:“25”}(或任何其他变量,如integer、Number、Number),我会收到错误消息,50(当前值)无法通过“in”访问。将数据类型更改为字符串正在工作。在SAP的示例中,我只能找到“string”和“SAP.ui.core.CSSSize”作为数据类型。如何定义数值?是

我正在为UI5开发一个组件。在metadata->properties部分,我想定义一个Integer类型的属性。如果我通过
“markerSize”设置数据类型:{type:“integer”,defaultValue:“25”}
(或任何其他变量,如integer、Number、Number),我会收到错误消息,50(当前值)无法通过“in”访问。将数据类型更改为字符串正在工作。在SAP的示例中,我只能找到“
string
”和“
SAP.ui.core.CSSSize
”作为数据类型。如何定义数值?是否有支持的数据类型列表及其正确定义

韩国,
Nico

如果使用int作为数据类型,则默认值不应是字符串(尽管它不会导致错误…)。您的问题是,您必须使用“int”而不是“integer”。因此,请在这里尝试:

{ type:"int",defaultValue: 25 }
这应该行得通。这个代码对我有用:

<script>

    sap.ui.core.Control.extend("my.Control", {
        metadata : {
            properties : {
                "text" : "string",
                "size" : {type: "int", defaultValue: 500 }
            },
        },

        renderer : function(oRm, oControl) {  
            oRm.write("<div>size = "+oControl.getSize()+"</div>") 
        }

    });

    var myControl = new my.Control({text:"Hello"});
    myControl.placeAt("content");        
</script>    

<body class='sapUiBody'>
    <div id='content'></div>
</body>

sap.ui.core.Control.extend(“my.Control”{
元数据:{
特性:{
“文本”:“字符串”,
“大小”:{类型:“int”,默认值:500}
},
},
渲染器:函数(oRm,oControl){
oRm.write(“size=“+oControl.getSize()+”)
}
});
var myControl=new my.Control({text:“Hello”});
myControl.placeAt(“内容”);

我希望这会有所帮助。

如果您使用int作为数据类型,那么您的defaultValue不应该是字符串(尽管它不会导致错误…)。您的问题是,您必须使用“int”而不是“integer”。因此,请在这里尝试:

{ type:"int",defaultValue: 25 }
这应该行得通。这个代码对我有用:

<script>

    sap.ui.core.Control.extend("my.Control", {
        metadata : {
            properties : {
                "text" : "string",
                "size" : {type: "int", defaultValue: 500 }
            },
        },

        renderer : function(oRm, oControl) {  
            oRm.write("<div>size = "+oControl.getSize()+"</div>") 
        }

    });

    var myControl = new my.Control({text:"Hello"});
    myControl.placeAt("content");        
</script>    

<body class='sapUiBody'>
    <div id='content'></div>
</body>

sap.ui.core.Control.extend(“my.Control”{
元数据:{
特性:{
“文本”:“字符串”,
“大小”:{类型:“int”,默认值:500}
},
},
渲染器:函数(oRm,oControl){
oRm.write(“size=“+oControl.getSize()+”)
}
});
var myControl=new my.Control({text:“Hello”});
myControl.placeAt(“内容”);

我希望这能有所帮助。

谢谢!解决了这个问题。我还有一个问题:其他数据类型呢?数组还是浮点数?您可以在UI5文档中阅读:属性至少由其名称和类型定义。此外,还可以定义属性的默认值。因此,可用的设置是:type:控件属性的数据类型。自动类型验证在UI5内核中完成。有效类型的示例有:字符串属性的字符串(默认)、数字属性的int或float、int[]等。对于数组,sap.ui.core.CSSSize用于自定义定义的type@user3042011确保突出显示正确的答案,以便其他用户看到。谢谢。抱歉迟到了。。。对于其他数据类型,您只需查看我的SAPUI5教程,尤其是。谢谢!解决了这个问题。我还有一个问题:其他数据类型呢?数组还是浮点数?您可以在UI5文档中阅读:属性至少由其名称和类型定义。此外,还可以定义属性的默认值。因此,可用的设置是:type:控件属性的数据类型。自动类型验证在UI5内核中完成。有效类型的示例有:字符串属性的字符串(默认)、数字属性的int或float、int[]等。对于数组,sap.ui.core.CSSSize用于自定义定义的type@user3042011确保突出显示正确的答案,以便其他用户看到。谢谢。抱歉迟到了。。。对于其他数据类型,您只需查看我的SAPUI5教程,尤其是。