从cookie中取出用户

This commit is contained in:
Captain.B 2020-02-13 14:31:57 +08:00
parent 89fd3c1f6b
commit 163912046b
1 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<template>
<el-dropdown size="medium" @command="handleCommand">
<span class="dropdown-link">
<i class="el-icon-caret-bottom el-icon--right"/>
{{currentUser.name}}<i class="el-icon-caret-bottom el-icon--right"/>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="personal">个人信息</el-dropdown-item>
@ -11,8 +11,18 @@
</template>
<script>
import Cookies from 'js-cookie';
const TokenKey = 'Admin-Token';
export default {
name: "MsUser",
computed: {
currentUser: () => {
let user = Cookies.get(TokenKey);
return JSON.parse(user);
}
},
methods: {
handleCommand(command) {
switch (command) {