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

    How to make viewport() responsive in computed property?

    Help
    3
    3
    960
    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.
    • mesqueeb
      mesqueeb last edited by

      I need to use one of the quasar breakpoints in Vue as a computed property.
      However, the viewport() doesn’t get updated when making the screen bigger / smaller…

      import { dom } from 'quasar'
      const { viewport } = dom
      let { width } = viewport()
      export default {
        computed: {
          vp () {      
            return width
          },
          ltSm () { return (this.vp < 768) },
        },
      

      Any ideas?

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

        My way would be http://quasar-framework.org/components/window-resize-observable.html

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

          Also notice in your code, you grab width once. No reason the width property would be reactive.

          I think…

          Maybe this would work?

           computed: {
              vp () {      
                return dom.viewport().width
              },
              ltSm () { return (this.vp < 768) },
            },
          

          Untested. Also take a look at what @wilcorrea posted

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