2016-04-16 04:20:35 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Vue.js tree-view demo</title>
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
font-family: Menlo, Consolas, monospace;
|
|
|
|
color: #444;
|
|
|
|
}
|
|
|
|
.item {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.bold {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
ul {
|
|
|
|
padding-left: 1em;
|
|
|
|
line-height: 1.5em;
|
|
|
|
list-style-type: dot;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script src="../../dist/vue.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<!-- item template -->
|
|
|
|
<script type="text/x-template" id="item-template">
|
|
|
|
<li>
|
|
|
|
<div
|
|
|
|
:class="{bold: isFolder}"
|
|
|
|
@click="toggle"
|
|
|
|
@dblclick="changeType">
|
|
|
|
{{model.name}}
|
|
|
|
<span v-if="isFolder">[{{open ? '-' : '+'}}]</span>
|
|
|
|
</div>
|
|
|
|
<ul v-show="open" v-if="isFolder">
|
|
|
|
<item
|
|
|
|
class="item"
|
|
|
|
v-for="model in model.children"
|
|
|
|
:model="model">
|
|
|
|
</item>
|
2016-06-09 01:28:55 +08:00
|
|
|
<li class="add" @click="addChild">+</li>
|
2016-04-16 04:20:35 +08:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<p>(You can double click on an item to turn it into a folder.)</p>
|
|
|
|
|
|
|
|
<!-- the demo root element -->
|
|
|
|
<ul id="demo">
|
|
|
|
<item
|
|
|
|
class="item"
|
|
|
|
:model="treeData">
|
|
|
|
</item>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!-- demo code -->
|
|
|
|
<script src="tree.js"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|