N00ts / vue3-treeview

a simple treeview in vue js 3
MIT License
71 stars 61 forks source link

Custom icons per node #9

Closed TechSupportJosh closed 2 years ago

TechSupportJosh commented 2 years ago

Hi there,

Is it possible to define an icon for a specific node? For example, if you're attempting to represent a file structure:

image

It would be nice to be able to override the "fakeIcon" inside TreeIcons.vue for something like this:

image

An example from codepen, where each file extension has a different icon:

image

Thank you!

N00ts commented 2 years ago

Hello, what is your use case ? Maybe you can use the slots to achieve this. If it does not fit you can customize open / close icon for each node.

TechSupportJosh commented 2 years ago

Slots worked perfectly well, thank you! Is it possible to make the slots (or the entire node) clickable, rather than just the icon?

N00ts commented 2 years ago

You can do what you want with the slots. For example, you can @click.stop to avoid propagation to parent. Here is an example for what you want to achieve (maybe reload needed)