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
cd7156cb
Commit
cd7156cb
authored
Oct 08, 2016
by
furybean
Committed by
cinwell.li
Oct 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Tree Bug: set data does not work
parent
8af8c8b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
packages/tree/src/model/node.js
packages/tree/src/model/node.js
+22
-17
packages/tree/src/tree.vue
packages/tree/src/tree.vue
+6
-0
No files found.
packages/tree/src/model/node.js
View file @
cd7156cb
...
...
@@ -28,7 +28,7 @@ const reInitChecked = function(node) {
const
getPropertyFromData
=
function
(
node
,
prop
)
{
const
props
=
node
.
props
;
const
data
=
node
.
data
;
const
data
=
node
.
data
||
{}
;
const
config
=
props
[
prop
];
if
(
typeof
config
===
'
function
'
)
{
...
...
@@ -69,23 +69,28 @@ export default class Node {
}
if
(
this
.
lazy
!==
true
&&
this
.
data
)
{
let
children
;
if
(
this
.
level
===
-
1
&&
this
.
data
instanceof
Array
)
{
children
=
this
.
data
;
}
else
{
children
=
getPropertyFromData
(
this
,
'
children
'
)
||
[];
}
this
.
setData
(
this
.
data
);
}
}
for
(
let
i
=
0
,
j
=
children
.
length
;
i
<
j
;
i
++
)
{
const
child
=
children
[
i
];
this
.
insertChild
(
new
Node
({
data
:
child
,
parent
:
this
,
lazy
:
this
.
lazy
,
load
:
this
.
load
,
props
:
this
.
props
}));
}
setData
(
data
)
{
this
.
data
=
data
;
let
children
;
if
(
this
.
level
===
-
1
&&
this
.
data
instanceof
Array
)
{
children
=
this
.
data
;
}
else
{
children
=
getPropertyFromData
(
this
,
'
children
'
)
||
[];
}
for
(
let
i
=
0
,
j
=
children
.
length
;
i
<
j
;
i
++
)
{
const
child
=
children
[
i
];
this
.
insertChild
(
new
Node
({
data
:
child
,
parent
:
this
,
lazy
:
this
.
lazy
,
load
:
this
.
load
,
props
:
this
.
props
}));
}
}
...
...
packages/tree/src/tree.vue
View file @
cd7156cb
...
...
@@ -68,6 +68,12 @@
}
},
watch
:
{
data
(
newVal
)
{
this
.
tree
.
root
.
setData
(
newVal
);
}
},
methods
:
{
getCheckedNodes
(
leafOnly
)
{
return
this
.
tree
.
getCheckedNodes
(
leafOnly
);
...
...
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