Why do I call the arr2 method three times in mount? how do I display the corresponding content of the lower input when the value of input changes? now it keeps showing, I can"t control it to show and hide in arr2
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="itany">
<ul class="form-ul">
<li class="form-item">
<h4 class="form-title"></h4>
<input type="text" v-model="name" class="form-input">
<i class="icon pen"></i>
</li>
</ul>
<p v-for="(v,k) in arr2" :key="k" v-show="flag">
{{v}}
</div>
<!---->
<script>
//export default{
// create(){
// this.request();
// },
// methods:{
// request(){
// }
//}
//}
//import axios from "./axios"
//Vue.prototype.$http = axios
var vm = new Vue({
el:"-sharpitany",
data:{
flag:false,
arr:["","alex","mark"],
name:""
},
//
created: function(){
},
computed:{
arr2:function () {
var temp=[];
//console.log(this.flag);
this.arr.forEach(val=> {
if(val.includes(this.name)){
this.flag=true;
temp.push(val);
console.log(this);
}
});
console.log(temp);
return temp;
}
}
})
</script>