ItSolutionStuff.com

How to Check Object or Array Empty or Not in Vue JS?

By Hardik Savani • June 30, 2023
Vue.JS

I will teach you how to check object is empty or not and check array is empty or not in vuejs app. this post will help you to check object or array empty or not using v-if and array.length.

If you are a using core jquery and you need to check array or object is empty or not then you can do it easily. In vue js you can't do it very simple, but you can do it using v-if and array.length.

So, just see bellow example and learn about that:

Example:

<!DOCTYPE html>

<html>

<head>

<title>How to check object or array empty or not in Vue JS? - ItSolutionStuff.com</title>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>

<body>

<ul id="app">

<li v-if="!items.length">No item found</li>

<li v-for="item in items">

</li>

</ul>

</body>

<script type="text/javascript">

var app = new Vue({

el: '#app',

data: {

items: []

}

});

</script>

</html>

I hope it can help you....

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Vue Dependent Dropdown Example

Read Now →

How to Create and Use Component in Vue JS Cli?

Read Now →

How to Use setTimeout Function in Vue JS?

Read Now →

How to Get Element by ID in Vue JS?

Read Now →

Laravel Vue Router Example From Scratch

Read Now →

Laravel Vue Flash Message Example From Scratch

Read Now →

Laravel Vue JS File Upload Using Vue-dropzone Example

Read Now →

Laravel Vue JS Image Upload Example

Read Now →

Laravel Vue JS Axios Post Request Example

Read Now →

Laravel Vue JS Infinite Scroll Example with Demo

Read Now →

Laravel Vue JS Pagination Example with Demo

Read Now →

Dynamic Dependent Dropdown using VueJS and PHP

Read Now →