plantain-00 / tree-component

A reactjs and vuejs tree component.
MIT License
146 stars 32 forks source link

Nothing rendered in vue3 #30

Open v1r0x opened 3 years ago

v1r0x commented 3 years ago

Version(if relevant): 6.0.1

Environment(if relevant):

Vue3

Code(if relevant):

<template>
    <div>
        <tree :data="data"></tree>
    </div>
</template>
<script>
import { Node, Tree } from "tree-vue-component";
export default {
        components: {
            node: Node,
            tree: Tree,
        },
        setup(props) {
            return {
                data: [
                  {
                    text: 'node 1',
                    value: { id: 1 },
                    state: {
                    opened: true
                    },
                    children: [
                    {
                        text: 'node 11',
                        value: { id: 11 }
                    },
                    {
                        text: 'node 12',
                        value: { id: 12 },
                        state: {
                        opened: true
                        },
                        children: [
                        {
                            text: 'node 121',
                            value: { id: 121 }
                        },
                        {
                            text: 'node 122',
                            value: { id: 122 }
                        },
                        {
                            text: 'node 123',
                            value: { id: 123 }
                        }
                        ]
                    }
                    ]
                },
            ],
            };
        }
    }
</script>

Expected:

Tree should be rendered

Actual:

No tree is rendered DOM only shows this where the tree should be rendered

<!--  -->
plantain-00 commented 3 years ago

Tree and Node expected to registered in app, locally registered components are not also available in subcomponents.

v1r0x commented 3 years ago

I also tried to register them globally, but that didn't work either. But I'll retry it later and report back.

v1r0x commented 3 years ago

I registered the components in my main script and it still didn't work to use them in my other component CustomTree.vue. But when used in my main component (the one I create the app with const app = createApp(App);) it works. Thanks for your help!

But is it possible to use your tree component in any other component than the main component in vue?