使用以下命令从javascript创建对象后
function createNextItem(item, where) {
component = Qt.createComponent(val);
sprite = component.createObject(where, {
"id": "currentitem",
"anchors.left": nextlabel.right,
"anchors.leftMargin": units.gu(4),
"anchors.verticalCenter": nextlabel.verticalCenter
});
if (sprite === null) {
// Error Handling
console.log("Error creating object");
}
}
如果我尝试添加"transform": Scale { xScale: 0.5 ; yScale: 0.5}
,我会收到SyntaxError: Unexpected token {
,但如果我执行此类"transform": "Scale { xScale: 0.5 ; yScale: 0.5}"
的操作,则无效...有什么帮助?
答案 0 :(得分:2)
没关系......我通过制作容器父项,缩放它然后在其中创建新对象来获得它,如下所示:
Item {
id: currentitem
transform: Scale { xScale: 0.5; yScale: 0.5}
Component.onCompleted: { Jsfile.createItemObjects(ChkItem.getCurrentItem(), currentitem)
}
}