Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Deleting element throw an error [BUG] #40

Open
oneart-dev opened this issue Oct 8, 2020 · 0 comments
Open

Deleting element throw an error [BUG] #40

oneart-dev opened this issue Oct 8, 2020 · 0 comments

Comments

@oneart-dev
Copy link

oneart-dev commented Oct 8, 2020

Hi, nice gallery, exactly what I need? thank you! But one thing have to be fixed.
I want to delete element from array without errors.

<vue-gallery-slideshow :images="$_.map(localImages, 'file_path')" :index="carouselModel" @close="carouselModel = null"></vue-gallery-slideshow>

methods: {
         removeFile(fileId) {
                this.localImages = this.localImages.filter((item) => {
                   return item.id !== fileId
         })
} 

Error:

Error in render: "TypeError: Cannot read property 'url' of undefined"

vue-gallery-slideshow.js:125

computed: {
      imageUrl: function imageUrl() {
        var img = this.images[this.imgIndex];

        if (typeof img === "string") {
          return img;
        }

        return img.url;    // <<<<<<------ HERE
      },

I believe it should be:

imageUrl: function imageUrl() {
        var img = this.images[this.imgIndex];

        if(!img)
          return null;

        if (typeof img === "string") {
          return img;
        }

        return img.url;    // <<<<<<------ HERE
      },
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant