官方v2.2.1版本已经提供获取半选中状态节点对象。
具体实现思路:
// 1. 先合并选中/半选中节点Id,请求传给后台。
[].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
this.tempKey === -666666 // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化
// 2. 给tree绑定数据时,通过tempKey移除之前添加的半选中状态节点Id。
var idx = this.menuIdList.indexOf(this.tempKey)
if (idx !== -1) {
this.menuIdList.splice(idx, this.menuIdList.length - idx)
}
this.$refs.menuListTree.setCheckedKeys(this.menuIdList)