samedi 3 novembre 2018

Vue.js - Can't use Blazy

I want to use Blazy package to lazy load images in my Vue.js project. I installed it via npm, but I just can't import it and use it. I put this code in the created method of App.vue:

const bLazy = new Blazy({})

And this code in a component used to display items with images:

<img src="placeholder" :data-src="image-src" class="w-100 rounded" :alt="name">

Now what I tried to import it and make it working:

import Blazy from 'blazy' => Didn't work.

import * as Blazy from 'blazy' => Didn't work.

require('blazy') => "ReferenceError: Blazy is not defined".

const Blazy = require('blazy') => Didn't work.

What is the right way to make it work?




Aucun commentaire:

Enregistrer un commentaire