多个相同子组件的情况下,如何在子组件中知道自己的index或key #6488
-
比如
nav组件:
nav-item组件:
问:如何在 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@ZHAOzn If I understood correctly, hope this helps for you |
Beta Was this translation helpful? Give feedback.
-
The only reliable way to determine the final index of an item is to look it up in the rendered vnode tree. I have a PoC project for this scenario: https://github.com/Justineo/vue-coupled. |
Beta Was this translation helpful? Give feedback.
-
自己加个index属性啊 |
Beta Was this translation helpful? Give feedback.
@ZHAOzn If I understood correctly, hope this helps for you
https://stackoverflow.com/questions/56658913/getting-index-of-each-component-inside-vues-slots
https://stackoverflow.com/questions/71017073/how-to-get-number-of-slot-in-a-vuejs-component