this.$http({ url: `${this.tableName}/login?username=${this.rulesForm.username}&password=${this.rulesForm.password}`, method: "post" }).then(({ data }) => { if (data && data.code === 0) { this.$storage.set("Token", data.token); this.$storage.set("role", this.rulesForm.role); this.$storage.set("sessionTable", this.tableName); this.$storage.set("adminName", this.rulesForm.username); this.$router.replace({ path: "/index/" }); } else { this.$message.error(data.msg); } }); },
时间: 2024-02-19 07:01:15 浏览: 14
这段代码是用来进行登录验证的。可以看出是一个 POST 请求,其中包含用户名和密码,请求的接口是`${this.tableName}/login`。在请求成功后,将Token、角色、sessionTable、管理员名称存储到浏览器的本地存储中,并且跳转到`/index/`页面。如果请求失败,则弹出错误信息。