navigateTo、relaunch、navigateBack、getCurrentPages

<template>
    <button @click="show">跳1</button>
    <button @click="hide">跳2</button>
    <button @click="back">回退</button>
</template>

<script setup>
    // 使用js代码跳转
    const show = () => {
        uni.navigateTo({
            url:'/pages/demo/rpx'
        })
    }
    // 跳转的open-type是relaunch模式
    const hide = () => {
        uni.reLaunch({
            url:'/pages/demo/image'
        })
    }
    // 回退
    const back = () => {
        uni.navigateBack(
            {
                delta: 1 // 是回退多少个路由,不写默认1
            }
        )
    }
    // getCurre能够获取路由栈,是数组存储的Vue实例信息
    console.log(getCurrentPages())
</script>

 

posted on 2025-03-01 18:54  ChoZ  阅读(9)  评论(0)    收藏  举报

导航