index.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vue.js tree view example</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. <!-- Delete ".min" for console warnings in development -->
  24. <script src="../../dist/vue.min.js"></script>
  25. </head>
  26. <body>
  27. <!-- item template -->
  28. <script type="text/x-template" id="item-template">
  29. <li>
  30. <div
  31. :class="{bold: isFolder}"
  32. @click="toggle"
  33. @dblclick="changeType">
  34. {{model.name}}
  35. <span v-if="isFolder">[{{open ? '-' : '+'}}]</span>
  36. </div>
  37. <ul v-show="open" v-if="isFolder">
  38. <item
  39. class="item"
  40. v-for="model in model.children"
  41. :model="model">
  42. </item>
  43. <li class="add" @click="addChild">+</li>
  44. </ul>
  45. </li>
  46. </script>
  47. <p>(You can double click on an item to turn it into a folder.)</p>
  48. <!-- the demo root element -->
  49. <ul id="demo">
  50. <item
  51. class="item"
  52. :model="treeData">
  53. </item>
  54. </ul>
  55. <!-- demo code -->
  56. <script src="tree.js"></script>
  57. </body>
  58. </html>