Created
July 15, 2016 22:29
-
-
Save pablohpsilva/2f566381c89b33677759debb71a4c5bf to your computer and use it in GitHub Desktop.
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
<style> | |
</style> | |
<template> | |
<div class="" v-for="item in list | formatResult filter"> | |
{{item}} | |
</div> | |
</template> | |
<script type="text/babel"> | |
export default { | |
data() { | |
list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], | |
filter: [] | |
}, | |
methods: { | |
createFilterStructure(id, args, func) { | |
return {id, args, func}; | |
}, | |
addFilterFunction(id, args, func) { | |
this.filter.push(this.createFilterStructure(id, args, func)); | |
} | |
}, | |
ready() { | |
this.addFilterFunction('odd', [], (list) => { return list.filter((el) => {return (el % 2 !== 0)})}); | |
this.addFilterFunction('greaterThan5', [], (list) => { return list.filter((el) => {return (el > 5)})}); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment