0
當在console.log()
函數用於我的委託組件的索引屬性不被識別:QML:委託的索引屬性不被認可的console.log()
onClicked: {
identities.qml_del_account(index);
console.log(index);
}
/*Application output:*/
qrc:/Accounts2.qml:74: ReferenceError: index is not defined
線74是這樣的:
console.log(index);
爲什麼它在第一行工作,但在第二行失敗?兩行都位於同一個javascript函數中。
完全QML代碼:
Identities {
id: identities
}
ListView {
id: list_identities
width: list_area.width
height: 100
model: identities
delegate: Rectangle {
id: identities_delegate
height: 40
width: parent.width
Text {
id: identities_item
height: parent.height
anchors.left: parent.left
width: 100
text: email
}
Image {
source: "qrc:/images/dots-menu.png"
id: toolbtn_img
anchors.right: parent.right
width: 24
height: 24
MouseArea {
width: parent.width
height: parent.height
onClicked: {
identities.qml_del_account(index);
console.log(index);
}
}
}
}
}
該模型是C++定義它,則爲功能qml_del_account()
的正常工作,我不是在抱怨。
你的猜測是完全正確的。非常感謝! – Nulik