index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view>
  3. <view v-for="(item,index) in treeList" :key="item.ldph" class="tree">
  4. <view class="head" @click="treeClick(item,index)">
  5. <image class="icon" :src="btn_unfold_normal_16" mode="" v-if="item.isClick && item.data"></image>
  6. <image class="icon" :src="btn_packup_normal_16" mode="" v-if="!item.isClick && item.data"></image>
  7. <view>{{ item.ldph }}</view>
  8. </view>
  9. <view v-if="item.isClick && item.data" class="children">
  10. <Tree :treeList="item.data" @node-click="nodeClick"></Tree>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'Tree',
  18. props: {
  19. treeList: {
  20. type: Array,
  21. default: []
  22. }
  23. },
  24. data() {
  25. return {
  26. btn_packup_normal_16: require('./img/btn_packup_normal_16.svg'),
  27. btn_unfold_normal_16: require('./img/btn_unfold_normal_16.svg')
  28. }
  29. },
  30. methods: {
  31. treeClick(item, i) {
  32. item.isClick = !item.isClick
  33. const parent = this.treeList
  34. const index = i
  35. this.nodeClick(item, parent, index)
  36. },
  37. nodeClick(item, parent, index) {
  38. this.$emit('node-click', item, parent, index)
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .tree {
  45. font-family: PingFangSC, PingFang SC;
  46. color: rgba(4, 8, 20, 1);
  47. // font-size: 14px;
  48. font-size: 56rpx;
  49. .head {
  50. display: flex;
  51. }
  52. .icon {
  53. // width: 36rpx;
  54. // height: 36rpx;
  55. width: 60rpx;
  56. height: 80rpx;
  57. }
  58. .children {
  59. // margin-left: 40rpx;
  60. margin-left: 60rpx;
  61. }
  62. }
  63. </style>