Antoine Saint-louis
Antoine Saint-louis

Reputation: 1

how to get length of array in Native script (vueJS)

I would like to know how I can get the length of my array in Native script /vue JS?

My code :

export default {
    data: () => {
        return {
            i: 0,
            log: [],
            img:[
                "~/Pictures/home.png",
                "~/Pictures/test.png"
                ],
        };
    },

Do you have an idea?

Upvotes: 0

Views: 210

Answers (1)

dummker
dummker

Reputation: 325

You could use a computed property for this.

Assuming you want the length of the img array:

export default {
  data() {
    return {
      img: ["~/Pictures/home.png", "~/Pictures/test.png"]
    };
  },
  computed: {
    imgArrayLength() {
      return this.img.length;
    }
  }
};
</script>

Upvotes: 1

Related Questions