vue 移动端仿hover事件

vue2.0的移动端的touch事件

touch的开始事件是@touchstart,

移动过程是@touchmove,

结束事件是@touchend

模仿hover效果,在PC端就是鼠标移入移出的效果,在移动端就是手指按下开始和结束的过程,上代码

<input class="immediately-btn" :class="{touchColor:whether}" type="button" value="立即领取" @touchstart="touchstart()" @touchend="touchend()">

css中给按钮设置一个颜色,touchColor是按下的颜色,wheter刚开始默认的是false

export default {
    data(){
        return{
            whether:false
        }
    },
    methods:{
        touchstart(){
            this.whether = true;
        },
        touchend(){
            this.whether = false;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/M_SSY/article/details/84840526