我正在尝试在 QML 中创建不同的上下文菜单,但我不知道正确的语法是什么。我想做类似的事情:
contextActions: [
ActionSet {
title: "Action Set"
subtitle: "This is an action set."
actions: if (_corporate.currentView == 2) {
[ ActionItem { title: "Action 1" },
ActionItem { title: "Action 2" },
ActionItem { title: "Action 3" } ]
} else {
[ActionItem { title: "Action 4" },
ActionItem { title: "Action 5" },
ActionItem { title: "Action 6" }
]
}
} // end of ActionSet
] // end of contextActions list
这显然是错误的语法,那么正确的方法是什么?提前致谢!