No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    My first vue component (using quasar) shows nothing in the browser

    Help
    5
    13
    4245
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rjansen
      rjansen last edited by

      I am making my first vue app (using Quasar). The Index.vue import my foo.vue compoment. And then I place a <foo> tag inside the template of Index.vue like this:

       ...<div class="layout-view">
              foo
              <foo></foo>
              bar
            <div class="logo-container non-selectable no-pointer-events">
              <div class="logo" :style="position">
                <img src="~assets/quasar-logo.png">
                <p class="caption text-center">
                  <span class="desktop-only">Move your mouse.</span>
                  <span class="touch-only">Touch screen and move.</span>
                </p>
              </div>
            </div>
          </div>...
      

      In the same Index.vue:

      ...
      <script>
          import { Utils } from 'quasar'
          import { Foo } from './foo.vue'
          ...
          components: {
              Foo
          }
      }
      </script>
      

      The foo.vue is this:

      <template>
        <!-- root node required -->
        <div>
          <!-- your content -->
          FOO
          <div class="layout-padding">
            <!-- if you want automatic padding -->
          </div>
        </div>
      </template>
      
      <script>
      export default {
        data () {
          return {}
        }
      }
      </script>
      
      <style>
      </style>
      

      I expect to see ‘FOO’ between ‘foo’ and ‘bar’ but there isn’t, there is ony ‘foo bar’. The build went well, no errors. What am I missing here?

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Did you use the CLI to scaffold the app first?

        Scott

        rjansen 1 Reply Last reply Reply Quote 0
        • rjansen
          rjansen @s.molinari last edited by

          @s.molinari I thought I did.

          1 Reply Last reply Reply Quote 0
          • M
            Max last edited by

            looks good so far! you must have something broken in your build setup

            1 Reply Last reply Reply Quote 0
            • s.molinari
              s.molinari last edited by

              I’ve recreated your scenario and it works fine for me, both with the dev server and serving up the /dist build.

              So, Max is probably right. You’re going to have to check your setup in general.

              Scott

              1 Reply Last reply Reply Quote 0
              • rjansen
                rjansen last edited by

                I have started over again, this time on a Linux machine (instead of Windows). Now I’m sure I used the quasar-cli to setup the app and run a dev server, exactly as the tutorial says. I also made a component (“quasar new component foo”). Still no ‘FOO’. But I’m not have made a build yet, I run the dev server right now (“quasar dev”).

                The error (seen it before but forgot to post, sorry):

                [Vue warn]: Unknown custom element: <foo> - did you register the component correctly? For recursive components, make sure to provide the “name” option.

                found in

                —> <Index> at /home/richard/jonathanapp/src/components/Index.vue
                <App> at /home/richard/jonathanapp/src/App.vue
                <Root>

                1 Reply Last reply Reply Quote 0
                • M
                  Max last edited by Max

                  using linux will generally result in less errors;)

                  can you show us your code again? component? main.js? including compoent…

                  1 Reply Last reply Reply Quote 0
                  • s.molinari
                    s.molinari last edited by s.molinari

                    Try also import Foo from 'components/foo.vue'

                    Scott

                    1 Reply Last reply Reply Quote 0
                    • rstoenescu
                      rstoenescu Admin last edited by

                      import { Foo } from './foo.vue' is wrong. It should be import Foo from './foo.vue'. You are trying to import the default export, not a named export from a component.

                      rjansen 1 Reply Last reply Reply Quote 0
                      • rjansen
                        rjansen last edited by

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • rjansen
                          rjansen @rstoenescu last edited by

                          @rstoenescu and @s-molinari This works! Thanks. So now I need to understand what te difference is, I will find that out.

                          1 Reply Last reply Reply Quote 0
                          • s.molinari
                            s.molinari last edited by

                            Look up ES6 modules.

                            Scott

                            1 Reply Last reply Reply Quote 0
                            • D
                              didymus last edited by didymus

                              I had the same issue, the importing with {} implies explicit modules within the JS document. While, including the name of the modules assumes it’s the name of the default module. import Foo from './foo.vue' for example Foo must be the default member of ```foo.vue``

                              I’m simply explaining this to reinforce my own learning and understanding of JS modules. I’ve been working with Javascript for a long time and I still forget.

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post