-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e212ea
commit 19fb1ea
Showing
4 changed files
with
59 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,70 @@ | ||
<template> | ||
<div class="test-tree"> | ||
<VueTree | ||
ref="tree4" | ||
:treeData="treeData" | ||
showCheckbox> | ||
|
||
<template v-slot="{ node, treeNode }"> | ||
<span style="color: #f00">{{node.name}}</span> | ||
<a class="link-color ml20" @click.stop="handleAddChild(treeNode)">增加</a> | ||
<a class="link-color ml20" @click.stop="handleRemoveChild(treeNode)">删除</a> | ||
<a class="link-color ml20" @click.stop="toggleDisable(node)">{{ node.disabled ? '开启' : '禁用'}}</a> | ||
</template> | ||
<template #expandIcon="{expanded, toggleFold, node}"> | ||
<div style="padding: 2px"> | ||
<div @click="toggleFold(node)" v-if="expanded">+</div> | ||
<div @click="toggleFold(node)" v-else>-</div> | ||
</div> | ||
</template> | ||
</VueTree> | ||
</div> | ||
<div class="test-tree"> | ||
<VueTree ref="tree4" :treeData="treeData" showCheckbox> | ||
<template v-slot="{ node, treeNode }"> | ||
<span style="color: #f00">{{ node.name }}</span> | ||
<a class="link-color ml20" @click.stop="handleAddChild(treeNode)" | ||
>增加</a | ||
> | ||
<a class="link-color ml20" @click.stop="handleRemoveChild(treeNode)" | ||
>删除</a | ||
> | ||
<a class="link-color ml20" @click.stop="toggleDisable(node)">{{ | ||
node.disabled ? "开启" : "禁用" | ||
}}</a> | ||
</template> | ||
<template #expandIcon="{expanded, toggleFold, node}"> | ||
<div class="c-expand" @click="toggleFold(node)" v-if="expanded">-</div> | ||
<div | ||
class="c-expand" | ||
@click="toggleFold(node)" | ||
v-else | ||
> | ||
+ | ||
</div> | ||
</template> | ||
</VueTree> | ||
</div> | ||
</template> | ||
<script> | ||
import { treeData } from '../../assets/treeData' | ||
import Mock from '../../utils/mock' | ||
import { treeData } from "../../assets/treeData"; | ||
import Mock from "../../utils/mock"; | ||
export default { | ||
name: 'Custom', | ||
data () { | ||
name: "Custom", | ||
data() { | ||
return { | ||
treeData, | ||
count: 0 | ||
} | ||
count: 0, | ||
}; | ||
}, | ||
updated () { | ||
console.log('updated') | ||
updated() { | ||
console.log("updated"); | ||
}, | ||
methods: { | ||
handleAddChild(treeNode) { | ||
this.maxId += 1 | ||
const { name } = Mock.mock({'name': "@ctitle(4,6)"}) | ||
this.maxId += 1; | ||
const { name } = Mock.mock({ name: "@ctitle(4,6)" }); | ||
const treeData = { | ||
id: this.maxId, | ||
name | ||
} | ||
this.$refs.tree4.appendChild(treeData, treeNode) | ||
name, | ||
}; | ||
this.$refs.tree4.appendChild(treeData, treeNode); | ||
}, | ||
handleRemoveChild(treeNode) { | ||
this.$refs.tree4.removeChild(treeNode) | ||
this.$refs.tree4.removeChild(treeNode); | ||
}, | ||
toggleDisable(node) { | ||
this.$set(node, 'disabled', !node.disabled) | ||
this.$set(node, "disabled", !node.disabled); | ||
}, | ||
} | ||
}, | ||
}; | ||
</script> | ||
<style> | ||
.c-expand { | ||
line-height: 12px; | ||
width: 12px; | ||
text-align: center; | ||
border: 1px solid #000; | ||
} | ||
</script> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters