Search code examples
nativescript-vue

Vue in nativescript


Is possible to have a component inside another component in nativescript vue? Like relation father-son

Like this:

<Frame ~mainContent>
    <Page>
        <ActionBar title="Initial Page" style="color:white">
            <NavigationButton icon="res://menu" @tap="openMenu"></NavigationButton>
        </ActionBar>

        <StackLayout>
           <son-component></son-component>
        </StackLayout>
    </Page>
</Frame>

Solution

  • This should do it. You need to register Son Component

    <Frame ~mainContent>
        <Page>
            <ActionBar title="Initial Page" style="color:white">
                <NavigationButton icon="res://menu" @tap="openMenu"></NavigationButton>
            </ActionBar>
    
            <StackLayout>
               <Son></Son>
            </StackLayout>
        </Page>
    </Frame>
    
    <script >
    import Son from "./son-component";
    
      export default {
        components: {
        Son,
      },
        props: {
    
      },
      data() {
    
      }
    }
    </script>