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