Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
7d094869
Commit
7d094869
authored
Jan 18, 2017
by
张华焱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tree]添加node-open与node-close事件,共三个参数,依次为:传递给 data 属性的数组中该节点所对应的对象、节点对应的 Node、节点组件本身。
parent
b137274a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
packages/tree/src/tree-node.vue
packages/tree/src/tree-node.vue
+2
-0
test/unit/specs/tree.spec.js
test/unit/specs/tree.spec.js
+41
-0
No files found.
packages/tree/src/tree-node.vue
View file @
7d094869
...
@@ -146,8 +146,10 @@
...
@@ -146,8 +146,10 @@
handleExpandIconClick
()
{
handleExpandIconClick
()
{
if
(
this
.
expanded
)
{
if
(
this
.
expanded
)
{
this
.
tree
.
$emit
(
'
node-close
'
,
this
.
node
.
data
,
this
.
node
,
this
);
this
.
node
.
collapse
();
this
.
node
.
collapse
();
}
else
{
}
else
{
this
.
tree
.
$emit
(
'
node-open
'
,
this
.
node
.
data
,
this
.
node
,
this
);
this
.
node
.
expand
();
this
.
node
.
expand
();
this
.
$emit
(
'
node-expand
'
,
this
.
node
.
data
,
this
.
node
,
this
);
this
.
$emit
(
'
node-expand
'
,
this
.
node
.
data
,
this
.
node
,
this
);
}
}
...
...
test/unit/specs/tree.spec.js
View file @
7d094869
...
@@ -369,4 +369,45 @@ describe('Tree', () => {
...
@@ -369,4 +369,45 @@ describe('Tree', () => {
},
DELAY
);
},
DELAY
);
},
DELAY
);
},
DELAY
);
});
});
it
(
'
handleNodeOpen & handleNodeClose
'
,
(
done
)
=>
{
vm
=
getTreeVm
(
'
:props="defaultProps" lazy :load="loadNode" @node-open="handleNodeOpen" @node-close="handleNodeClose"
'
,
{
methods
:
{
loadNode
(
node
,
resolve
)
{
if
(
node
.
level
===
0
)
{
return
resolve
([{
label
:
'
region1
'
},
{
label
:
'
region2
'
}]);
}
if
(
node
.
level
>
4
)
return
resolve
([]);
setTimeout
(()
=>
{
resolve
([{
label
:
'
zone
'
+
this
.
count
++
},
{
label
:
'
zone
'
+
this
.
count
++
}]);
},
50
);
},
handleNodeOpen
(
data
,
node
,
vm
)
{
this
.
currentNode
=
data
;
this
.
nodeExpended
=
true
;
},
handleNodeClose
(
data
,
node
,
vm
)
{
this
.
currentNode
=
data
;
this
.
nodeExpended
=
false
;
}
}
});
const
firstNode
=
document
.
querySelector
(
'
.el-tree-node__content
'
);
expect
(
firstNode
.
nextElementSibling
.
childNodes
.
length
).
to
.
equal
(
0
);
firstNode
.
click
();
setTimeout
(()
=>
{
expect
(
vm
.
nodeExpended
).
to
.
equal
(
true
);
expect
(
vm
.
currentNode
.
label
).
to
.
equal
(
'
region1
'
);
firstNode
.
click
();
setTimeout
(()
=>
{
expect
(
vm
.
nodeExpended
).
to
.
equal
(
false
);
expect
(
vm
.
currentNode
.
label
).
to
.
equal
(
'
region1
'
);
done
();
},
100
);
},
100
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment