首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel 5.3 Passport - Vue错误:计算表达式时出错

Laravel 5.3 Passport - Vue错误:计算表达式时出错
EN

Stack Overflow用户
提问于 2016-09-04 17:13:29
回答 1查看 1.3K关注 0票数 0

这两天让我头疼。我最近将我的laravel应用程序更新到5.3,在我的本地环境中,我拉入了Laravel/passport。安装完成后,一切都会按预期运行。

当我将此更新推送到生产服务器时,一切仍然正常,但vue在passport组件上抛出错误。我仍然是vue的新手,我找不到是什么导致了这种情况。

我尝试的最后一件事是在生产服务器上重新安装Laravel和passport,这导致了相同的错误。当我将此安装推送到本地计算机时,一切都正常。我猜这是某种依赖错误。

以下是错误:

代码语言:javascript
复制
[Vue warn]: Error when evaluating expression "token.scopes.length > 0": TypeError: Cannot read property 'length' of undefined (found in component: <passport-authorized-clients>)
[Vue warn]: Error when evaluating expression "token.client.name": TypeError: Cannot read property 'name' of undefined (found in component: <passport-authorized-clients>)
[Vue warn]: Error when evaluating expression "token.scopes.length > 0": TypeError: Cannot read property 'length' of undefined (found in component: <passport-authorized-clients>)
[Vue warn]: Error when evaluating expression "token.client.name": TypeError: Cannot read property 'name' of undefined (found in component: <passport-authorized-clients>)

有没有人遇到过同样的错误,我该如何解决这个问题?

编辑:我设法修复了这个问题。我将php5.6更新为php7,并安装了以下PHP模块: libgmp-dev、php-gmp。当我再次进行全新安装时,npm抱怨passport需要两个依赖项: mdanter/ecc和indigophp/hash-compat

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-23 17:59:58

我也遇到过同样的问题。here的解决方案帮助了我。它建议在resources/assets/js/bootstrap.js中添加以下内容

代码语言:javascript
复制
Vue.http.interceptors.push((request, next ) => {
    next((response) => {
        if( 'Content-Type' in response.headers 
            && response.headers['Content-Type'] == 'application/json' ){
            if( typeof response.data != 'object' ){
                response.data = JSON.parse( response.data );
            }
        }

        if( 'content-type' in response.headers
            && response.headers['content-type'] == 'application/json' ){
            if( typeof response.data != 'object' ){
                response.data = JSON.parse( response.data );
            }
        }
    });
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39315341

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档