:::demo A node's data is not fetched until it is clicked, so the Tree cannot predict whether a node is a leaf node. That's why a drop-down button is added to each node, and if it is a leaf node, the drop-down button will disappear when clicked. That being said, you can also tell the Tree in advance whether the node is a leaf node, avoiding the render of the drop-down button before a leaf node.
```html
<el-tree
:props="props1"
:props="props"
:load="loadNode1"
lazy
show-checkbox>
...
...
@@ -148,7 +148,7 @@ Used for node selection.
exportdefault{
data(){
return{
props1:{
props:{
label:'name',
children:'zones',
isLeaf:'leaf'
...
...
@@ -186,7 +186,7 @@ The checkbox of a node can be set as disabled.
:::demo In the example, 'disabled' property is declared in defaultProps, and some nodes are set as 'disabled:true'. The corresponding checkboxes are disabled and can't be clicked.
```html
<el-tree
:data="data3"
:data="data"
:props="defaultProps"
show-checkbox
@check-change="handleCheckChange">
...
...
@@ -196,7 +196,7 @@ The checkbox of a node can be set as disabled.
exportdefault{
data(){
return{
data3:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -242,7 +242,7 @@ Tree nodes can be initially expanded or checked
:::demo Use `default-expanded-keys` and `default-checked-keys` to set initially expanded and initially checked nodes respectively. Note that for them to work, `node-key` is required. Its value is the name of a key in the data object, and the value of that key should be unique across the whole tree.
```html
<el-tree
:data="data2"
:data="data"
show-checkbox
node-key="id"
:default-expanded-keys="[2, 3]"
...
...
@@ -254,7 +254,7 @@ Tree nodes can be initially expanded or checked
exportdefault{
data(){
return{
data2:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -305,7 +305,7 @@ Tree nodes can be initially expanded or checked
:::demo This example shows how to get and set checked nodes. They both can be done in two approaches: node and key. If you are taking the key approach, `node-key` is required.
```html
<el-tree
:data="data2"
:data="data"
show-checkbox
default-expand-all
node-key="id"
...
...
@@ -350,7 +350,7 @@ Tree nodes can be initially expanded or checked
data(){
return{
data2:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -405,7 +405,7 @@ The content of tree nodes can be customized, so you can add icons or buttons as
<divclass="block">
<p>Using render-content</p>
<el-tree
:data="data4"
:data="data"
show-checkbox
node-key="id"
default-expand-all
...
...
@@ -416,7 +416,7 @@ The content of tree nodes can be customized, so you can add icons or buttons as
<divclass="block">
<p>Using scoped slot</p>
<el-tree
:data="data5"
:data="data"
show-checkbox
node-key="id"
default-expand-all
...
...
@@ -483,8 +483,8 @@ The content of tree nodes can be customized, so you can add icons or buttons as
}]
}];
return{
data4:JSON.parse(JSON.stringify(data)),
data5:JSON.parse(JSON.stringify(data))
data:JSON.parse(JSON.stringify(data)),
data:JSON.parse(JSON.stringify(data))
}
},
...
...
@@ -543,7 +543,7 @@ Tree nodes can be filtered
<el-tree
class="filter-tree"
:data="data2"
:data="data"
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
...
...
@@ -568,7 +568,7 @@ Tree nodes can be filtered
data(){
return{
filterText:'',
data2:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -689,7 +689,7 @@ You can drag and drop Tree nodes by adding a `draggable` attribute.
:::demo
```html
<el-tree
:data="data6"
:data="data"
node-key="id"
default-expand-all
@node-drag-start="handleDragStart"
...
...
@@ -707,7 +707,7 @@ You can drag and drop Tree nodes by adding a `draggable` attribute.
@@ -138,7 +138,7 @@ Usado para la selección de nodos.
:::demo Los datos de un nodo no son cargados hasta que no es pinchado, así que el árbol no puede predecir si es una hoja. Por eso a cada nodo se le añade el botón de desplegar, y si el nodo es una hoja el botón desaparecerá al pinchar en él. También puede decirle al árbol que el nodo es una hoja de antemano, y así evita que muestre el botón de desplegar.
```html
<el-tree
:props="props1"
:props="props"
:load="loadNode1"
lazy
show-checkbox>
...
...
@@ -148,7 +148,7 @@ Usado para la selección de nodos.
exportdefault{
data(){
return{
props1:{
props:{
label:'name',
children:'zones',
isLeaf:'leaf'
...
...
@@ -186,7 +186,7 @@ El checkbox de un nodo se puede poner como desactivado.
:::demo En el ejemplo, la propiedad 'disabled' se declara en defaultProps, y algunos nodos se ponen como 'disabled:true'. Los checkboxes correspondientes son desactivados y no se pueden pinchar.
```html
<el-tree
:data="data3"
:data="data"
:props="defaultProps"
show-checkbox
@check-change="handleCheckChange">
...
...
@@ -196,7 +196,7 @@ El checkbox de un nodo se puede poner como desactivado.
exportdefault{
data(){
return{
data3:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -242,7 +242,7 @@ Los nodos pueden estar desplegados o seleccionados por defecto.
:::demo Utilice `default-expanded-keys` y `default-checked-keys` para establecer los nodos desplegados y seleccionados respectivamente. Tenga en cuenta que para que funcione es necesario que tengan `node-key`. Su valor es el nombre de una clave en el objeto data, y el valor de la clave debe ser único en todo el árbol.
```html
<el-tree
:data="data2"
:data="data"
show-checkbox
node-key="id"
:default-expanded-keys="[2, 3]"
...
...
@@ -254,7 +254,7 @@ Los nodos pueden estar desplegados o seleccionados por defecto.
exportdefault{
data(){
return{
data2:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -305,7 +305,7 @@ Los nodos pueden estar desplegados o seleccionados por defecto.
:::demo Este ejemplo muestra como establecer y leer nodos seleccionados. Esto se puede hacer por nodos o por claves. Si lo hace por claves el atributo `node-key` es necesario.
```html
<el-tree
:data="data2"
:data="data"
show-checkbox
default-expand-all
node-key="id"
...
...
@@ -350,7 +350,7 @@ Los nodos pueden estar desplegados o seleccionados por defecto.
data(){
return{
data2:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -405,7 +405,7 @@ El contenido de los nodos puede ser personalizado, así que puede añadir iconos
<divclass="block">
<p>Using render-content</p>
<el-tree
:data="data4"
:data="data"
show-checkbox
node-key="id"
default-expand-all
...
...
@@ -416,7 +416,7 @@ El contenido de los nodos puede ser personalizado, así que puede añadir iconos
<divclass="block">
<p>Using scoped slot</p>
<el-tree
:data="data5"
:data="data"
show-checkbox
node-key="id"
default-expand-all
...
...
@@ -483,8 +483,8 @@ El contenido de los nodos puede ser personalizado, así que puede añadir iconos
}]
}];
return{
data4:JSON.parse(JSON.stringify(data)),
data5:JSON.parse(JSON.stringify(data))
data:JSON.parse(JSON.stringify(data)),
data:JSON.parse(JSON.stringify(data))
}
},
...
...
@@ -543,7 +543,7 @@ Los nodos del árbol se pueden filtrar.
<el-tree
class="filter-tree"
:data="data2"
:data="data"
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
...
...
@@ -568,7 +568,7 @@ Los nodos del árbol se pueden filtrar.
data(){
return{
filterText:'',
data2:[{
data:[{
id:1,
label:'Level one 1',
children:[{
...
...
@@ -689,7 +689,7 @@ Puede arrastrar y soltar nodos de Tree añadiendo un atributo `draggable` .
:::demo
```html
<el-tree
:data="data6"
:data="data"
node-key="id"
default-expand-all
@node-drag-start="handleDragStart"
...
...
@@ -707,7 +707,7 @@ Puede arrastrar y soltar nodos de Tree añadiendo un atributo `draggable` .
@@ -138,7 +138,7 @@ Vous pouvez activer la sélection des noeuds.
:::demo Les données d'un noeud ne sont pas accessibles tant que la noeud n'est pas cliqué, l'arbre ne peut donc pas prédire si un noeud sera une feuille. C'est pourquoi un bouton de menu est ajouté à chaque noeud, et si c'est une feuille il disparaîtra après le clic. Vous pouvez également dire par avance à l'arbre si un noeud est une feuille, pour éviter l'apparition du bouton de menu.
```html
<el-tree
:props="props1"
:props="props"
:load="loadNode1"
lazy
show-checkbox>
...
...
@@ -148,7 +148,7 @@ Vous pouvez activer la sélection des noeuds.
exportdefault{
data(){
return{
props1:{
props:{
label:'name',
children:'zones',
isLeaf:'leaf'
...
...
@@ -186,7 +186,7 @@ Les checkbox des noeuds peuvent être désactivées individuellement.
:::demo Dans cet exemple, la propriété `disabled` est ajoutée à `defaultProps`, et certains noeuds ont `disabled:true`. Les checkbox correspondantes sont donc désactivées.
```html
<el-tree
:data="data3"
:data="data"
:props="defaultProps"
show-checkbox
@check-change="handleCheckChange">
...
...
@@ -196,7 +196,7 @@ Les checkbox des noeuds peuvent être désactivées individuellement.
exportdefault{
data(){
return{
data3:[{
data:[{
id:1,
label:'Niveau un 1',
children:[{
...
...
@@ -243,7 +243,7 @@ Certains noeuds peuvent être ouverts et/ou sélectionnés par défaut.
:::demo Utilisez `default-expanded-keys` et `default-checked-keys` pour réglez respectivement les noeuds ouverts et les noeuds sélectionnés par défaut. Notez que `node-key` est requis dans ce cas. Sa valeurs est le nom d'une clé dans l'objets data, et sa valeur devrait être unique dans tout l'arbre.
```html
<el-tree
:data="data2"
:data="data"
show-checkbox
node-key="id"
:default-expanded-keys="[2, 3]"
...
...
@@ -255,7 +255,7 @@ Certains noeuds peuvent être ouverts et/ou sélectionnés par défaut.
exportdefault{
data(){
return{
data2:[{
data:[{
id:1,
label:'Niveau un 1',
children:[{
...
...
@@ -306,7 +306,7 @@ Certains noeuds peuvent être ouverts et/ou sélectionnés par défaut.
:::demo Cet exemple montre comment récupérer et sélectionner des noeuds. Vous pouvez utiliser deux approches: les noeuds ou les clés. Dans le cas des clés, `node-key` est requis.
```html
<el-tree
:data="data2"
:data="data"
show-checkbox
default-expand-all
node-key="id"
...
...
@@ -351,7 +351,7 @@ Certains noeuds peuvent être ouverts et/ou sélectionnés par défaut.
data(){
return{
data2:[{
data:[{
id:1,
label:'Niveau un 1',
children:[{
...
...
@@ -407,7 +407,7 @@ Le contenu des noeuds peut être personnalisé, afin de pouvoir ajouter des icô
<divclass="block">
<p>Avec render-content</p>
<el-tree
:data="data4"
:data="data"
show-checkbox
node-key="id"
default-expand-all
...
...
@@ -418,7 +418,7 @@ Le contenu des noeuds peut être personnalisé, afin de pouvoir ajouter des icô
<divclass="block">
<p>Avec un slot</p>
<el-tree
:data="data5"
:data="data"
show-checkbox
node-key="id"
default-expand-all
...
...
@@ -485,8 +485,8 @@ Le contenu des noeuds peut être personnalisé, afin de pouvoir ajouter des icô
}]
}];
return{
data4:JSON.parse(JSON.stringify(data)),
data5:JSON.parse(JSON.stringify(data))
data:JSON.parse(JSON.stringify(data)),
data:JSON.parse(JSON.stringify(data))
}
},
...
...
@@ -546,7 +546,7 @@ Les noeuds peuvent être filtrés par mot-clé.
<el-tree
class="filter-tree"
:data="data2"
:data="data"
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
...
...
@@ -571,7 +571,7 @@ Les noeuds peuvent être filtrés par mot-clé.
data(){
return{
filterText:'',
data2:[{
data:[{
id:1,
label:'Niveau un 1',
children:[{
...
...
@@ -692,7 +692,7 @@ Vous pouvez déplacer les noeuds par drag'n drop en ajoutant l'attribut `draggab
:::demo
```html
<el-tree
:data="data6"
:data="data"
node-key="id"
default-expand-all
@node-drag-start="handleDragStart"
...
...
@@ -710,7 +710,7 @@ Vous pouvez déplacer les noeuds par drag'n drop en ajoutant l'attribut `draggab