Home  >  Q&A  >  body text

How to load (installed) components in Vue Composition API

<p>I'm trying to load <code>vue3-burger-menu</code>, but the documentation is only for the <code>Options API</code>. On the other hand, I'm using the <code>Composition API</code>, but I'm a bit stuck. </p> <p>The documentation says this:</p> <pre class="brush:php;toolbar:false;">import { Slide } from 'vue3-burger-menu' // import the CSS transitions you wish to use, in this case we are using `Slide` export default { components: { Slide // Register your component } }</pre> <p>But <code>export defaults</code> doesn't work for me. </p> <p>So, how do I load <code>slideshows</code>? </p>
P粉010967136P粉010967136391 days ago432

reply all(1)I'll reply

  • P粉151466081

    P粉1514660812023-08-29 00:00:30

    Here is a working playground with vue3-burger-menu example.

    https://stackblitz.com/edit/vue-wwkpny ?file=src/App.vue

    You must put the code in the question into a custom component.

    like this:

    MyMenu.vue

    <template>
        <Slide>
          <a id="home" href="#">
            <span>Home</span>
          </a>
        </Slide>
    </template>
    
    <script>
    import { Slide } from 'vue3-burger-menu'  // import the CSS transitions you wish to use, in this case we are using `Slide`
    
    export default {
        components: {
            Slide // Register your component
        }
    }
    </script>

    and use it in your application:

    App.vue

    <template>
      <div id="app">
        <MyMenu />
      </div>
    </template>
    
    <script>
    import MyMenu from './components/MyMenu.vue'
    
    export default {
      name: 'App',
      components: {
        MyMenu
      }
    }
    </script>

    reply
    0
  • Cancelreply