How do render-style tree components gracefully bind click events?

how do render-style tree components in iview gracefully bind click events?

work needs to use custom tree components, using iview components, but after using render, you can only write click events in the render function, so there will be multiple click events in the render function, which appears to be redundant and not elegant. Is there any other way to write it?

related codes

<template>
  <div class="fss-tree" @click="clickHandler">
    <Tree :data="treeData" :render="renderContent" ref="reference"></Tree>
  </div>
</template>

<script>
import { Menu, Tree } from "iview"
export default {
  name: "fss-tree",
  components: {
    Menu,
    Tree
  },
  data() {
    return {
      treeData: [
        {
          title: "parent 1",
          expand: true,
          render: (h, { root, node, data }) => {
            return h(
              "span",
              {
                style: {
                  display: "inline-block",
                  width: "50%"
                },
                on: {
                  click() {
                    // console.log(`root: ${JSON.stringify(root)}`)
                    // console.log(`node: ${JSON.stringify(node)}`)
                    // console.log(`data: ${JSON.stringify(data)}`)
                    // data.expand = !data.expand
                  }
                }
              },
              [
                h("span", [
                  h("Icon", {
                    props: {
                      type: "ios-folder-outline"
                    },
                    style: {
                      marginRight: "8px"
                    }
                  }),
                  h("span", data.title)
                ])
              ]
            )
          },
          children: [
            {
              title: "child 1-1",
              expand: true,
              children: [
                {
                  title: "leaf 1-1-1",
                  expand: true
                },
                {
                  title: "leaf 1-1-2",
                  expand: true
                }
              ]
            },
            {
              title: "child 1-2",
              expand: true,
              children: [
                {
                  title: "leaf 1-2-1",
                  expand: true
                },
                {
                  title: "leaf 1-2-1",
                  expand: true
                }
              ]
            }
          ]
        }
      ],
      buttonProps: {
        type: "ghost",
        size: "small"
      }
    }
  },
  methods: {
    renderContent(h, { root, node, data }) {
      return h("span",
        {
          style: {
            display: "inline-block",
            width: "60%"
          }
        },
        [
          h("span", [
            h("Icon", {
              props: {
                type: data.title.includes("child") ? "ios-folder-outline" : "ios-paper-outline"
              },
              style: {
                marginRight: "8px"
              }
            }),
            h("span", data.title)
          ])
        ]
      )
    },
    clickHandler() {
      console.log(this.$refs.reference)
    }
  }
}
</script>
Mar.31,2021

are you conscious of implementing click events for specific items in tree? Whether or not to call a method can be determined according to the condition in click.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3fbcf-2b1fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3fbcf-2b1fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?