<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/vue.min.js"></script>
</head>
<body>
<div id="itany">
<ul class="form-ul">
<li class="form-item">
<h4 class="form-title"></h4>
<ele-input v-on:name="handleList"></ele-input>
<!-- <my-input :value="item" @input="val => {item = val}"></my-input>-->
<i class="icon pen"></i>
</li>
</ul>
<ul class="form-ul">
<li class="form-item" v-for="(v,k) in Arr" :key="k">
{{v}}
</li>
</ul>
</div>
<script>
Vue.component(
"eleInput",{
template: "<input type="text" @input="pushArr" v-model="name" >\
",
data: function(){
return{
name:""
}
},
methods:{
pushArr: function () {
this.$emit("name",{item:this.name});
}
}
}
)
var vm=new Vue({
el:"-sharpitany",
data:function(){
return{
Arr:[],
Arrpost:["","", "alex", "mark"]
};
},
methods:{
handleList: function (payload) {
var temp=[];
this.Arrpost.forEach(
function(val){
if(val.indexOf(payload.item)!=-1&&(payload.item!="")){
temp.push(val);
}
}
);
this.Arr=temp;
}
}
})
</script>
</body>
</html>
Please put < li class= "form-item" v) in Arr in the above code
ele-inputhttps://cn.vuejs.org/v2/guide/components.html-sharp