index.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vue.js tree-view demo</title>
  6. <style>
  7. body {
  8. font-family: Menlo, Consolas, monospace;
  9. color: #444;
  10. }
  11. .item {
  12. cursor: pointer;
  13. }
  14. .bold {
  15. font-weight: bold;
  16. }
  17. ul {
  18. padding-left: 1em;
  19. line-height: 1.5em;
  20. list-style-type: dot;
  21. }
  22. </style>
  23. <script src="../../dist/vue.js"></script>
  24. </head>
  25. <body>
  26. <!-- item template -->
  27. <script type="text/x-template" id="item-template">
  28. <li>
  29. <div
  30. :class="{bold: isFolder}"
  31. @click="toggle"
  32. @dblclick="changeType">
  33. {{model.name}}
  34. <span v-if="isFolder">[{{open ? '-' : '+'}}]</span>
  35. </div>
  36. <ul v-show="open" v-if="isFolder">
  37. <item
  38. class="item"
  39. v-for="model in model.children"
  40. :model="model">
  41. </item>
  42. <li @click="addChild">+</li>
  43. </ul>
  44. </li>
  45. </script>
  46. <p>(You can double click on an item to turn it into a folder.)</p>
  47. <!-- the demo root element -->
  48. <ul id="demo">
  49. <item
  50. class="item"
  51. :model="treeData">
  52. </item>
  53. </ul>
  54. <!-- demo code -->
  55. <script src="tree.js"></script>
  56. </body>
  57. </html>