0
In general, this is the kind of complexity that calls for a component, but from your trouble with <slot>
I’m seeing that your use case must be somewhat complex and there may be reasons why you want to avoid making a component for this.
To your original question, assuming you already have some id
field to index your table cells, you can make hovered
a dictionary and index it with the same field. Note that due to vue reactivity limitations of javascript you can’t use hovered[item.id] = 1
because it won’t react, so you have to use $set(hovered, item.id, 1)
:
data: function () { return {
hovered: {}
}
<td @mouseenter="$set(hovered, item.id, 1)"
@mouseleave="$set(hovered, item.id, 0)">
<button v-show="hovered[item.id]">
-1
Should be doable using directives:
Source:stackexchange.com