Skip to content

Instantly share code, notes, and snippets.

@jessijean
Created November 8, 2019 06:26
Show Gist options
  • Save jessijean/c59e9d06bebe206d4a69b65f9f825d74 to your computer and use it in GitHub Desktop.
Save jessijean/c59e9d06bebe206d4a69b65f9f825d74 to your computer and use it in GitHub Desktop.
Vue.js Check Data Array Length for V-if
<!DOCTYPE html>
<html>
<head>
<title>Check Data Object Array Length & Hide When Empty</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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment