在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 請教下vue的input獲得焦點事件

請教下vue的input獲得焦點事件

目前我想做一個登錄框,在登錄框上有一個圖片,如果username的input獲得了焦點,就顯示圖1,如果password獲得了焦點,就顯示圖2,請問應(yīng)該怎么寫才對?
一開始我是這樣寫的:

<img :src='imgurl'>

在input上面寫了@focus='test'
然后再methods下面寫了個test事件
更改不了imgurl

回答
編輯回答
局外人

是否在 focus 事件中 更改的時候 圖片的src沒有轉(zhuǎn)換
最好把你的代碼貼上來一下

2017年10月11日 17:10
編輯回答
挽歌

能改呀,不知道你怎么寫的,是蘋果瀏覽器的話貌似要把focus換成click,還是用click吧

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="box">
       <input type="text" @focus="aaa()" /> 
       <input type="password" @focus="bbb()"/>
       <img :src="url"/>
    </div>
   <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>

           var vm = new  Vue({
            el:"#box",
            data:{
               url:"http://www.xuxin123.com/code/waterfall/images/33.jpg"
             },
             methods:{
                 aaa:function(){
                     this.url="http://www.xuxin123.com/code/waterfall/images/33.jpg";
                 },
                 bbb:function(){
                     this.url="http://www.xuxin123.com/code/waterfall/images/32.jpg";
                 }
             },
             mounted () {
              
            }
    
            
        });
    </script>
</body>
</html>
2017年8月21日 08:22
編輯回答
帥到炸

獲取焦點是@focus 失去焦點是@blur

2017年12月5日 19:22
編輯回答
尛憇藌
<img :src="show" alt="">
<input type="text" @focus="handleinput()">

methods:{
    handleinput(){
            this.show=""
        },
}
2017年1月9日 14:35