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

    Using Loading plugin

    Help
    2
    2
    825
    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.
    • G
      gkentsidis last edited by

      Can someone please help me on how to use the ‘Loading’ plugin? I have a Layout that routes to some pages. I want to show a spinner when loading the app layout and another one when loading each page (on-demand). Where do I call this.$q.loading.show() and hide() ?

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

        Do you have ajax requests in each page?
        Loading spinners are great as long as you have to wait for asynchronous data loads. So you can call this.$q.loading.show() before an async function, promise or callback and this.$q.loading.hide() after it resolves. For example in a promise:

        this.$q.loading.show()
        
        new Promise(resolve => {
          setTimeout(() => {
            resolve()
          }, 3000)
        }).then(() => {
           this.$q.loading.hide()
        })
        
        

        If the asynchronous data is called entering at a page, you may call this.$q.loading.show() into created hook and hide it after initialization:

        export default {
          name: 'App',
        
          data () {
            return {
              data: []
            }
          },
        
          methods: {
            getContent () {
              return this.$axios.get('content').then(res => res.data)
            }
          },
        
          created: async function () {
            this.$q.loading.show()
            this.content = await this.getContent()
            this.$q.loading.hide()
          }
        }
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post