forked from fanruan/fineui-custom-tutorials
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.2 KiB
1.2 KiB
父节点不可选中的树
props结构
{
expander: {
type: "bi.expander",
isDefaultInit: false,
el: {},
popup: {
type: "bi.custom_tree",
},
},
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [
{
type: "bi.vertical",
},
],
},
items:[]
}
node实现
父节点不可选中,也就是点击父节点就触发展开收起操作,node的实现直接继承BI.NodeButton即可,第一节中提到的NodeButton的关键API大部分都无需override.除了setOpened方法. 一般在setOpened中处理展开收起按钮的样式改变等
setOpened: function (b) {
Node.superclass.setOpened.apply(this, arguments);
// 额外的自定义处理,如加号变成减号,三角箭头由→改为↓
}
item实现
子节只涉及选中业务,不涉及展开收起业务,所以直接继承BasicButton即可,无需override任何方法
其他公共实现
- 可以手动实现getValue方法,或者在构建items生成value属性
- 选中样式可以采用
bi-list-item
、bi-list-item-active
、bi-list-item-active2
、bi-list-item-none
等样式