Want to pass Vuejs dynamic filter (here dynamic refers to the condition of the filter is dynamic change),
I've never found a good way.
The stupidest way of course is two two arrays, one as an array of views as the original copy array, so that when the filter conditions change
Dynamically copy the original array filtered results to the view array, which allows Vuejs to perceive our view array changes and then update the view
This is stupid, and the copy is a waste of time, the code below
<HTML><Head> <Scriptsrc= "Http://cdn.bootcss.com/vue/2.1.4/vue.js"></Script></Head><Body> <DivID= "App"> <!--<li v-for= "N in Even (persons)" >{{N.name}}</li> - <Liv-for= "N in Personsview">{{N.name}}:: {{n.age}}</Li> <inputtype= "text"V-model= "Age"placeholder= "Age" /> </Div></Body><Scripttype= "Text/javascript"> varapp= NewVue ({el:'#app', Data: {Age:0, persons: [{name:'Zhang San', Age: -}, {name:'John Doe', Age: +}, {name:'Harry', Age:Ten}], personsview:[{name:'Zhang San', Age: -}, {name:'John Doe', Age: +}, {name:'Harry', Age:Ten}]}, methods: {even:function(persons) {returnPersons.filter (function(p) {returnP.age>= Ten; })}, watch:{Age:function(val,oldval) {Console.log ('NEW:%s, old:%s', Val, oldval); Console.log ( This. Persons.filter (function(p) {returnP.age>=Val; }). Slice ()); This. Personsview= This. Persons.filter (function(p) {returnP.age>=Val; }). Slice (); } } });</Script></HTML>
Who has a better way of doing this, you gotta tell me.
Dynamic filtering of Vuejs