python web全栈,  python全栈,  前端开发

登录退出-实现退出功能

利用window.sessionStorage.clear() 将本地token 情况

用this.$router.push 编程式路由将页面跳转到登录也面

<template>
    <div>
        <el-button @click="logout">退出</el-button>
    </div>
</template>

<script>
    export default {
        name: "Home",
        methods: {
            logout() {
                // 删除本地的token
                window.sessionStorage.clear();
                // 用编程式路由跳转到登录页面
                this.$router.push('/login')
            }
        }
    }
</script>

<style scoped>

</style>

留言

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

闽ICP备20008591号-1