TreeNode.vue 660 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <div class="node-container" :style="nodeStyle">
  3. <el-card class="node-card">
  4. {{title}}
  5. </el-card>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. name: "TreeNode",
  11. props:{
  12. title: String,
  13. positionY: Number,
  14. positionX: Number
  15. },
  16. computed:{
  17. nodeStyle(){
  18. return {
  19. top: (this.positionY*120)+'px',
  20. left: (300*this.positionX)+'px'
  21. }
  22. }
  23. }
  24. }
  25. </script>
  26. <style scoped>
  27. .node-container{
  28. width: 300px;
  29. height: 120px;
  30. box-sizing: border-box;
  31. position: absolute;
  32. display: flex;
  33. justify-content: center;
  34. align-items: center;
  35. }
  36. .node-card{
  37. width: 260px;
  38. height: 100px;
  39. background-color: #42b983;
  40. }
  41. </style>