Calculation of property: think Italy is also a named property can be called directly using interpolation expression
Ado, directly on the code:
Page section
<!-- 用户名下拉菜单 --> <el-dropdown class="user-name" trigger="click" @command="handleCommand"> <span class="el-dropdown-link"> {{username}} <i class="el-icon-caret-bottom"></i> </span> <el-dropdown-menu slot="dropdown"> <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item> </el-dropdown-menu> </el-dropdown>
js part
computed: { username() { let userSO = sessionStorage.getItem("userSO",userSO); let username =userSO.userName; return username; /* let username = localStorage.getItem("ms_username"); return username ? username : "admin"; */ } },