tree-root上下键的默认行为是高亮选中,但是不会激活,只有当按了enter才会有点击选中的效果
1 定义tree-root的actionMapping
//.ts
//自定义tree-root的action,需放在类的外面
const actionMapping: IActionMapping = {
keys: {
[KEYS.UP]: (tree, node, $event) => {
TREE_ACTIONS.PREVIOUS_NODE(tree, node, $event);
tree.getFocusedNode().setIsActive(true);
},
[KEYS.DOWN]: (tree, node, $event) => {
TREE_ACTIONS.NEXT_NODE(tree, node, $event);
tree.getFocusedNode().setIsActive(true);
}
}
};
export class Test extends AppComponentBase implements OnInit, OnDestroy {
options: ITreeOptions = { actionMapping, idField: 'key' }
}
2 在tree-root中绑定你定义的options
.html
<tree-root [options]