本文介绍: 回到上一页代码uniapp中代码。

回到上一页代码uniapp中代码
在这里插入图片描述

<template>
	<view class="my_footer">
		<view class="m_goBack" @click.stop="handlergoBack()"></view>
		<view class="m_index"  @click.stop="handlergoIndex()"></view>
	</view>
</template>

<script>
	export default {
		methods: {
			//回到上一个页面
			handlergoBack() {
				//如果没有上一个页面 就回到首页
				const pages = getCurrentPages();
				if (pages.length === 2) {
					uni.navigateBack({
						delta: 1
					});
				} else if (pages.length === 1) {
					uni.switchTab({
						url: '/pages/index/index',
					})
				} else {
					uni.navigateBack({
						delta: 1
					});
				}
			},
			//回到首页
			handlergoIndex(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			}

		}
	}
</script>

<style lang="scss">
	.my_footer {
		background: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 96rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 88;
		.m_index {
			flex: 1;
			height: 96rpx;
			background: url('@/static/home.png') center no-repeat;
			background-size: 32rpx 30rpx;
			
		}
		.m_goBack {
			flex: 1;
			width: 80rpx;
			height: 96rpx;
			background: url('@/static/back.png') center no-repeat;
			background-size: 20rpx 32rpx;
		}
	}
</style>

原文地址:https://blog.csdn.net/weixin_45041493/article/details/135520317

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_56304.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注