为了账号安全,请及时绑定邮箱和手机立即绑定

vue中如何控制input的对应内容的显示隐藏

vue中如何控制input的对应内容的显示隐藏

杨__羊羊 2019-05-25 15:15:16
在mount时,为什么会调用三次arr2的方法,我怎么在input的值改变的时候才显示下方input的对应内容,现在一直显示,我无法在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}}    </p></div><!--循环绑定--><script>    //export default{    //   create(){    //       this.request();    //   },    //   methods:{    //    request(){      //    }    //}    //}    //import axios from './axios'     //Vue.prototype.$http = axios    var vm = new Vue({        el:'#itany',        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>
查看完整描述

5 回答

?
当年话下

TA贡献1890条经验 获得超9个赞

https://img1.sycdn.imooc.com//5c99d6f500018d0407980160.jpg

把v-show 改成v-if 试试


查看完整回答
反对 回复 2019-05-26
?
守着一只汪

TA贡献1872条经验 获得超3个赞


@change事件不就好了么?按你的表达? 涉及计算属性什么事?



查看完整回答
反对 回复 2019-05-26
  • 5 回答
  • 0 关注
  • 2021 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信