javascript - How to pass events out of a tree component written recursively in VUE?
漂亮男人
漂亮男人 2017-06-30 09:59:45
0
2
834

Due to recursive components, this kind of nesting will occur

<tree>
    <tree>
        <tree>

        </tree>
    </tree>
</tree>

It’s easy to select the outermost one. Dynamically register a Vuex module. Whichever one is clicked will be passed to this module.

But it is troublesome to implement click and $emit events in the tree structure. They are nested layer by layer and it is almost impossible to broadcast

Please tell me how to solve this problem

漂亮男人
漂亮男人

reply all(2)
我想大声告诉你

You can use $on and $emit:

Custom events

淡淡烟草味

The officially recommended approach is to use a Vue instance as the event bus.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!