<template>
	<view class="content">
		 <view :class="test" @touchstart="gtouchstart" @touchmove="gtouchmove" @click="cilckevent" @touchend="touchend"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				startX:'',
				startY:'',
				moveEndX:'',
				moveEndY:'',
				X:'',
				Y:'',
				test:'testsd'
			} 
		},
		onLoad() {

		},
		methods: {
			gtouchstart(e){ //按下事件
				console.log(e,'1,按下啦啦啦啦啦')
		    this.startX = e.changedTouches[0].pageX,
		    this.startY = e.changedTouches[0].pageY;
			},
			cilckevent(e){  //点击事件
				console.log(e,'你点击了')
			},
			touchend(){//结束触摸事件
				setTimeout(()=>{
					this.test='testend'
				},90)
				console.log('结束触摸事件')
			},
			gtouchmove(e){ //移动事件
		    this.moveEndX = e.changedTouches[0].pageX,
		    this.moveEndY = e.changedTouches[0].pageY,
		    this.X = this.moveEndX - this.startX,
		    this.Y =this.moveEndY - this.startY;
		    if ( Math.abs(this.X) > Math.abs(this.Y) && this.X > 0 ) {
		     	console.log("left 2 向左滑动");
					this.test='testleft'
		    }
		    else if ( Math.abs(this.X) > Math.abs(this.Y) && this.X < 0 ) {
					this.test='testfff'
					console.log('向右滑动')
		    }
		    else if ( Math.abs(this.Y) > Math.abs(this.X) && this.Y > 0) {
					console.log('向上滑动')
					this.test='testtop'
		    }
		    else if ( Math.abs(this.Y) > Math.abs(this.X) && this.Y < 0 ) {
					console.log('向下滑动')
					this.test='testbootom'
		    }
		    else{
		      console.log("just touch");
		    }
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-top: 200rpx;
	}
	.car-cond-cent{
		background: #007AFF;
		height: 2000rpx;
		width: 100%;
	}
	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
		margin-bottom: 50rpx;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.testsd{
		width: 80%;
		text-align: center;
		background-color: #C0C0C0;
		height: 500rpx;
		font-size: 50px;
	}
	.testfff{
		width: 80%;
		height: 500rpx;;
		text-align: center;
		background-color: #C0C0C0;
		font-size: 50px;
		-webkit-transition: 0.3s;
		transition: 0.3s;
		-webkit-transform: rotate(20deg);
		transform: rotate(10deg) translateX(-50px)
	}
	.testleft{
		width: 80%;
		height: 500rpx;;
		text-align: center;
		background-color: #C0C0C0;
		font-size: 50px;
		-webkit-transition: 0.3s;
		transition: 0.3s;
		-webkit-transform: rotate(-20deg);
		transform: rotate(-10deg) translateX(50px)
	}
	.testend{
		width: 80%;
		height: 500rpx;
		text-align: center;
		background-color: #C0C0C0;
		font-size: 50px;
		-webkit-transition: 0.3s;
		transition: 0.5s;
		-webkit-transform: rotate(0deg);
		transform: rotate(0deg);
	}
	.testbootom{
		transform: translateY(-10%);
		width: 80%;
		height: 500rpx;
		text-align: center;
		background-color: #C0C0C0;
		font-size: 50px;
		-webkit-transition: 0.3s;
		transition: 0.5s;
	}
	.testtop{
		transform: translateY(10%);
		width: 80%;
		height: 500rpx;
		text-align: center;
		background-color: #C0C0C0;
		font-size: 50px;
		-webkit-transition: 0.3s;
		transition: 0.5s;
	}
</style>

GitHub 加速计划 / vu / vue
101
18
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:1 个月前 )
9e887079 [skip ci] 11 个月前
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐