RoseEnd

2747 经验值

上传头像之后提示token错误,能上传成功,但是上传的modal框一直停留在正在上传...不会自动关闭了,这个怎么解决?

Uncaught SyntaxError: Unexpected token r in JSON at position 1
    at JSON.parse (<anonymous>)
    at XMLHttpRequest.client.onreadystatechange (eval at <anonymous> (app-83e06ee75d.js:927), <anonymous>:744:38)

我使用的时候可以提示错误了,但是我再次点击发送的时候就会成功发送空数据,这个怎么解决?

点赞的时候出现`vue.js?3de6:485 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "count"

found in

---> <UserVoteButton> at /home/vagrant/Code/zhihu.app/resources/assets/js/components/UserVoteButton.vue

   <Root>~~这个错误,但是功能可以正常使用!

把之前一个用户删了之后,随便登录一个其他账号,打开首页就会出现Trying to get property of non-object错误

给你个大大的赞,你眼神果然毒辣,这都能发现!

其他地方也没用到这个啊,我是按照你教程一步一步来的,//window.Laravel.apiToken = "{ Auth::check() ? 'Bearer '.Auth::user()->api_token : 'Bearer ' }";这段代码注释掉就正常

app.blade.php:

    <script>
        window.Laravel = <?php echo json_encode([
            'csrfToken' => csrf_token(),

        ]); ?>
        Laravel.apiToken = "{ Auth::check() ? 'Bearer '.Auth::user()->api_token : 'Bearer ' }";
    </script>

bootstrap.js:

    Vue.http.interceptors.push((request, next) => {
    request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
    request.headers.set('Authorization', Laravel.apiToken);

    next();
});

值可以获取到,但是就是不能点击关注按钮,

    <script>
        window.Laravel = {"csrfToken":"Aq2ztvmUKPzAr79MaqrRKbsQojLtLXqJv0kVKzvQ"}        
        Laravel.apiToken = "Bearer a7QDv8acuI13hOW7aYEITerZb7Q9B17IeAUjV43Vy1WQE7yVTEXipyFDv9ZU";
    </script>

添加api_token的时候报出如下错误:

ReferenceError: Laravel is not defined
at VueComponent.eval (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:83:1), <anonymous>:30:41)
at exec (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:146:1), <anonymous>:1149:29)
at VueComponent.eval (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:146:1), <anonymous>:1178:13)
at Promise (<anonymous>)
at new PromiseObj (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:146:1), <anonymous>:199:24)
at Client (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:146:1), <anonymous>:1142:16)
at Object.Http (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:146:1), <anonymous>:1399:12)
at Function.Http.(anonymous function) [as post] (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:146:1), <anonymous>:1438:20)
at VueComponent.mounted (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:115:1), <anonymous>:16:20)
at callHook (eval at <anonymous> (http://zhihu.app/build/js/app-4f163be99d.js:152:1), <anonymous>:2669:21)

怎么解决?

不好意思,我发错了,本来想删掉的,结果没删除按钮,下次不会!