O'Reilly logo

The Majesty of Vue.js by Kostas Maniatis, Alex Kyriakidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filtered results

Sometimes we need to display a filtered version of an array without actually mutating or resetting the original data. In our example, we want to display a list with the stories written by Alex and one list with the stories written by John. We can achieve this by using the built-in filter, filterBy:

<html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> <title>User Stories</title> </head> <body> <div class="container"> <h1>Let's hear some stories!</h1> <div> <h3>Alex's stories</h3> <ul class="list-group"> <li v-for="story in stories | filterBy 'Alex' in 'writer'" class="list-group-item" > {{ story.writer }} said "{{ story.plot }}" </li> </ul> <h3>John's stories</h3> <ul ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required