[Vuejs]-How to remove empty string in JSON file?

2👍

Multiple ways to solve this problem.

You can use filter() in javascript (or something similar in other frameworks)

const filteredData = jsonData.filter(obj => Object.values(obj).some(val => val !== ""));

Another way to solve it would be to check for empty strings before rending the IMG component in Nuxt.

<Grid class="sponsors">
  <Img v-for="prop in home" :src="prop.sponsors" :width="300" v-if="prop.sponsors !== ''" />
</Grid>

Leave a comment