如何基于安装的Vue中的角色来阻止触发请求-Laravel Vue API令牌认证用户

问题描述

我有一个方法,当在我的已装载的Vue页面中加载时,会调用并返回经过身份验证的用户

mounted() {
        User.auth()
            .then(response => {
                this.user = response.data;
                this.role = response.data.roles[0];

                console.log(response.data);
            })
            .catch(error => (this.user = ""));
    },

还有另一种方法,此后我要根据用户角色进行控制

User.allUser().then(response => {
             this.users = response.data;
             console.log(response.data);
         });

在触发第二种方法之前,我如何获得角色名称并进行比较?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)