我有以下代码:
Item {
width: fos.width; height: fos.height
Rectangle {
id: fos
width: 120; height: 120
color: "red"
MouseArea {
anchors.fill: parent
onClicked: {
if (fos.color == "red") fos.color = "gray"
else fos.color = "red"
}
}
}
}
我想在单击Rectangle
时更改颜色MouseArea
。但是,代码不起作用。我的错在哪里?