vue长按事件

摘要:
url=')[1]);location.href=url;},//开始按gtouchstart:functiontouchstart{this.timeOutEvent=setTimeout;//在此处设置计时器,定义长按500毫秒触发的长按事件,时间可以自己更改。就个人而言,500毫秒非常适合returnfalse;},//手动释放。如果在500毫秒内释放,则取消长按事件。此时,您可以执行事件gtouchend:functiongtouchend{clearTimeout;//如果(this.timeOutEvent!

<template>
<div class="authorization">
<div class="main">
<div class="login-logo">
<img :src="http://t.zoukankan.com/logo" alt="">
<div class="text-item">快乐论文</div>
</div>
</div>
<div class="outter">
<div class="main-footer">
<div class="txt-item-title">
微信收款验证成功,请按如下步骤操作:
</div>
<div class="txt-item-title">
请点击“领红包首页”,填写订单号获得返现
</div>
<v-touch tag="div" v-bind: v-on:tap="onTap">
确认登录
</v-touch>
<div @touchstart="gtouchstart(v)" @touchmove="gtouchmove()" @touchend="gtouchend(v)" class="hahah">12345</div>
</div>
</div>
</div>
</template>

<script>
export default {
name: 'authorization',
data () {
return {
logo: require('./../assets/login_logo.jpg'),
redbug: false,
timeOutEvent: 0,
v:'test'
};
},
methods: {
onTap: function() {
this.redbug = !this.redbug;
let url = decodeURIComponent(location.href.split('?url=')[1]);
location.href = url;
},
//开始按
gtouchstart:function gtouchstart(item){
this.timeOutEvent = setTimeout(function(){
},500);//这里设置定时器,定义长按500毫秒触发长按事件,时间可以自己改,个人感觉500毫秒非常合适
return false;
},
//手释放,如果在500毫秒内就释放,则取消长按事件,此时可以执行onclick应该执行的事件
gtouchend:function gtouchend(item){
clearTimeout(this.timeOutEvent);//清除定时器
if(this.timeOutEvent!=0){
//这里写要执行的内容(尤如onclick事件)
alert(123);
}
return false;
},
//如果手指有移动,则取消所有事件,此时说明用户只是要移动而不是长按
gtouchmove:function gtouchmove(){
clearTimeout(this.timeOutEvent);//清除定时器
this.timeOutEvent = 0;

},

//真正长按后应该执行的内容
longPress:function longPress(item){
this.timeOutEvent = 0;
//执行长按要执行的内容,如弹出菜单
alert(1223);
}
}
}
</script>
<style lang="scss">
$browser-default-font-size: 50px !default;
@function pxTorem($px) {
@return $px / $browser-default-font-size * 1rem;
}
$background:#FFFFFF;
#app {
background:$background;
}
.main {
background:$background;
font-size:pxTorem(16px);
100%;
height:pxTorem(178px);
}
.login-logo {
80%;
margin:0 auto;
box-sizing:border-box;
}
.login-logo img {
pxTorem(80px);
height:pxTorem(80px);
margin:0 auto;
margin-left:50%;
position:relative;
left:pxTorem(-40px);
top:pxTorem(35px);
}
.text-item {
margin-left:50%;
position:relative;
left:pxTorem(-40px);
top:pxTorem(48px);
color:black;
font-size:pxTorem(20px);
}
.outter {
100%;
height:pxTorem(424px);
background:$background;
}
.main-footer {
85%;
height:100%;
border-top:pxTorem(0.9px) solid #E7E7E7;
margin:0 auto;
}
.main-footer div:first-child {
font-size:pxTorem(16px);
margin-top:pxTorem(36px);
color:black;
}
.main-footer div:nth-child(2) {
margin-top:pxTorem(20px);
font-size:pxTorem(14px);
color:grey;
}
.main-footer div:nth-child(2)::before {
content:'●';
color:#858585;
font-size:pxTorem(10px);
padding-right:pxTorem(10px);
}
.f-primary-btn {
100%;
background:#07BE02;
margin:0 auto;
margin-top:pxTorem(33px);
text-align:center;
height:pxTorem(40px);
border-radius:pxTorem(5px);
line-height:pxTorem(40px);
color:white;
font-size:pxTorem(20px);
}
.red {
background:#039702;
color:#51B441;
}
.hahah {
pxTorem(100px);
height:pxTorem(100px);
background:red;
}
</style>

免责声明:文章转载自《vue长按事件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇变量的命名规则及命名规范拓端数据tecdat|R语言中实现广义相加模型GAM和普通最小二乘(OLS)回归下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Vue日历控件

<html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible"content="IE=edge"> <title>测试</title> <!--引入样式 -->...

vue项目搜索历史功能的实现

播放器项目中歌曲搜素页面的 首先需要在state定义搜索历史,在其中保存搜索历史 state.js:// 搜索历史: searchHistory: []  mutations中新增改变搜索历史的方法 mutations.js:SET_SEARCH_HISTORY(state, history) { state.searchHistory = hi...

vue histroy模式去除#页面刷新访问空白原因以及解决办法

开启history模式: 如果不开启的话,路由默认是hash模式,开启这个模式前端的工作也很简单,如下: mode: 'history' //在路由那里配置一下这个 如图标记1所示 https://www.XXXXX.com/data/#/login // => 就替换成 https://www.XXXXX.com/data/login 先用h...

vue router:解决相同路径不同路由参数跳转同一页面,路由参数不动态刷新的问题

问题描述 当我们使用同一路径跳转不同页面时,路由参数不会刷新,所以组件中接收不到,比如我的路由定义和路由跳转链接如下:当然我们人为不肯直接这样写啦~这里模拟问题写的demo 采用 watch 监听 1. 在点击跳转的组件中使用 watch 进行检测动态改变路由参数: watch: { // 利用watch方法检测路由变化:进行重新赋值 $r...

vuex的使用,vuex辅助函数、muduld的详解(文章下边)

1)什么事Vuex&nbsp;&nbsp;&nbsp;&nbsp;Vuex是一个专为Vue.js应用程序开发的状态管理模式---所有页面共享的变量2)Vuex在什么情况下进行使用在项目过大的时候采取使用,项目量较小的时候是繁琐冗余的官网的说如果您不打算开发大型单页应用,使用 Vuex 可能是繁琐冗余的。确实是如此——如果您的...

vue中使用触摸事件,上滑,下滑,等

第一步,下载一个包 npm install kim-vue-touch -s在当前项目中下载包第二部 import vueTouch from 'kim-vue-touch' Vue.use(vueTouch) kim-vue-touch提供了点击、长按、左滑、右滑、上滑、下滑等事件, 当你不需要传参时可以通过v-tap="vueTouch"的形式调用...