A Pen by thinsoldier on CodePen.
Last active
August 20, 2017 21:47
-
-
Save thinsoldier/97799004d86fa25856b7247f6cbe9f6f to your computer and use it in GitHub Desktop.
VueJs 2 vs JQuery Comparision - vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://youtu.be/HQDkXTlgY14 --> | |
<div id="app"> | |
<input type="text" v-model="query"> Full Regular Expression Search (case insensitive) | |
<ul> | |
<li v-for="item in filteredItems">{{item}}</li> | |
</ul> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Vue({ | |
el:"#app", | |
data:{ | |
query:'', | |
items:['red','Apple','Banana','Orange','Facebook','Twitter','Youtube'] | |
}, | |
computed:{ | |
filteredItems:function() | |
{ | |
var self=this; | |
return self.items.filter(function(val){ | |
return Array.isArray( val.match( new RegExp(self.query, 'i') ) ); | |
}); | |
} | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/vue"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment