question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

initial image is showing up as "not found" with nuxt

See original GitHub issue

Hi

When implementing vue-lazyload in nuxt, I see the following result in my browser (please also refer to the picture below):

  1. image is “not found” as the alt text is shown
  2. the loading placeholder image is shown
  3. the actual image is shown

problem

Why is it that I see this first step, i.e. the image that is not being found? This is very weird behaviour and I do not manage to solve this problem.

This is my config:

lazyload.client.js plugin:

import Vue from 'vue'
import VueLazyload from 'vue-lazyload'

import loading from '../assets/images/placeholder.png'

Vue.use(VueLazyload, {
  loading
})

And I have this in my template:

<template functional>
  <figure class="image is-3by2">
    <img v-lazy="props.src" :alt="props.alt" />
  </figure>
</template>

<script>
export default {
  props: {
    src: {
      type: String,
      required: true
    },
    alt: {
      type: String,
      required: true
    }
  }
}
</script>

nuxt.config.js file excerpt:

export default {
  mode: 'universal',
  plugins: [
    '~/plugins/lazyload.client.js'
  ],
  ...
}
````

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:11
  • Comments:14

github_iconTop GitHub Comments

7reactions
miteyemacommented, Nov 25, 2019

@jrah No, sorry, I still have that problem…

1reaction
Martin7mindcommented, Jun 16, 2020

img:not([src]) { display: none; }

this seems to work in chrome, to hide the broken images until the javascript set the src-attribute

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - image not found in assets when using @error in Nuxt
Show activity on this post. Based on this you need to use require because images inside assets directory are considered as modules :...
Read more >
nuxt-img
Uses built-in provider to optimize local and remote images · Converts src to provider optimized URLs · Automatically resizes images based on width...
Read more >
Nuxt - The Intuitive Vue Framework
Build your next Vue.js application with confidence using Nuxt. An open source framework making web development simple and powerful.
Read more >
Static directory - Nuxt
If you don't want to use Webpack assets from the assets directory, you can add the images to the static directory. In your...
Read more >
Plugins directory - Nuxt
If you get an Cannot use import statement outside a module error, you may need to add your package to the build >...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found