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

    bug in q-img v-else

    Framework
    3
    7
    353
    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.
    • I
      Incremental last edited by

      Hello, I have a conditional rendering of images
      The v-else is working and render “shop-logo.svg” in the following code :

      		<q-img
      			v-if="image && image.blob"
      			:src="image.blob"
      		/>
      		<q-img
      			v-else-if="image && image.url"
      			:src="image.url"
      		/>
      		<img v-else src="~assets/shop-logo.svg" />
      	</div>
      

      but not with <q-img> :

      		<q-img
      			v-if="image && image.blob"
      			:src="image.blob"
      		/>
      		<q-img
      			v-else-if="image && image.url"
      			:src="image.url"
      		/>
      		<q-img v-else src="~assets/shop-logo.svg" />
      	</div>
      

      It doesn’t render anything.
      Do I miss something, or it could be a bug ? Thanks

      dobbel 2 Replies Last reply Reply Quote 0
      • dobbel
        dobbel @Incremental last edited by

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

          @incremental

          Does this work at all without the v-else? :

          <q-img  src="~assets/shop-logo.svg" />
          
          
          I 1 Reply Last reply Reply Quote 0
          • I
            Incremental @dobbel last edited by

            @dobbel
            displays no image :
            <q-img src="~assets/shop-logo.svg" />
            <q-img v-else src="~assets/shop-logo.svg" />

            displays the image :
            <img v-else src="~assets/shop-logo.svg" />
            <img src="~assets/shop-logo.svg" />

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

              @incremental said in bug in q-img v-else:

              assets

              what if you put the svg in statics?

              <q-img src="statics/shop-logo.svg"/>
              

              Or

              <q-img  :src="shop_logo"/>
              
              import shop_logo_svg from 'src/assets/shop-logo.svg'
              ...
              data() {
                ....
                shop_logo : undefined
              }
              created() {
                this.shop_logo = shop_logo_svg
              }
              
              I 1 Reply Last reply Reply Quote 0
              • metalsadman
                metalsadman last edited by metalsadman

                @incremental https://github.com/quasarframework/quasar/issues/4763 try the workarounds in that ticket. Relative path or what dobbel suggested above.

                1 Reply Last reply Reply Quote 0
                • I
                  Incremental @dobbel last edited by Incremental

                  @dobbel I created a static directory and put my svg file. It’s the same, I get no image.

                  I tried your code, but it’s the same.
                  … and works with <img :src=“shop_logo”/>

                  As it works with a .jpg file, I will change my picture for a .jpg
                  Thanks

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