ant-design/components/tree/demo/checkbox.md

85 lines
1.5 KiB
Markdown
Raw Normal View History

2015-08-19 11:41:44 +08:00
# 可选择
2015-08-06 09:17:40 +08:00
- order: 1
提供复选框操作功能。
---
````jsx
var Tree = antd.Tree;
var TreeNode = Tree.TreeNode;
2015-08-24 18:12:07 +08:00
var velocity = antd.velocity;
2015-08-19 12:18:10 +08:00
function handleCheck(info) {
console.log('check: ', info);
}
2015-08-24 18:12:07 +08:00
const animation = {
enter(node, done){
var ok = false;
function complete() {
if (!ok) {
ok = 1;
done();
}
}
node.style.display='none';
velocity(node, 'slideDown', {
duration: 300,
complete: complete
});
return {
stop: function () {
velocity(node, 'finish');
// velocity complete is async
complete();
}
};
},
leave(node, done){
var ok = false;
function complete() {
if (!ok) {
ok = 1;
done();
}
}
velocity(node, 'slideUp', {
duration: 300,
complete: complete
});
return {
stop: function () {
velocity(node, 'finish');
// velocity complete is async
complete();
}
};
},
};
React.render(<div>
{React.cloneElement(<Tree defaultExpandAll={true} checkable={true} onCheck={handleCheck}>
2015-08-10 20:23:18 +08:00
<TreeNode title="parent 1">
2015-08-24 18:12:07 +08:00
<TreeNode title="leaf" />
2015-08-10 20:23:18 +08:00
<TreeNode title="parent 1-1">
<TreeNode title="parent 2-1">
2015-08-24 18:12:07 +08:00
<TreeNode title="leaf" />
<TreeNode title="leaf" />
2015-08-06 09:17:40 +08:00
</TreeNode>
2015-08-24 18:12:07 +08:00
<TreeNode title="leaf" />
2015-08-10 20:23:18 +08:00
</TreeNode>
</TreeNode>
2015-08-24 18:12:07 +08:00
</Tree>, {
openAnimation: animation,
})}
</div>
2015-08-06 09:17:40 +08:00
, document.getElementById('components-tree-demo-checkbox'));
````