应用实时聊天时未定义Laravel

时间:2017-11-21 22:59:13

标签: php laravel laravel-5

这是我的代码,

window.Laravel = {!! json_encode([

            'csrfToken' => csrf_token(),
            'user' => [
            'authenticated' => auth()->check(),
            'id' => auth()->check() ? auth()->user()->id : null,
            'name' => auth()->check() ? auth()->user()->name : null
            ],

            'keys' => [
                'pusher' => config('broadcasting.connections.pusher.key')
            ]

         ])!!};

这是bootstrap.js中的代码

 import Echo from "laravel-echo"

window.Pusher = require('pusher-js');

  window.Echo = new Echo({
     broadcaster: 'pusher',
     key: Laravel.keys.pusher
  });

我收到此错误

app.js:28113 Uncaught ReferenceError: Laravel is not defined
    at Object.VERSION (app.js:28113)
    at __webpack_require__ (app.js:20)
    at Object.defineProperty.value (app.js:28043)
    at __webpack_require__ (app.js:20)
    at Object.<anonymous> (app.js:28028)
    at __webpack_require__ (app.js:20)
    at app.js:63
    at app.js:66

window.Echo = new __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default.a({
  broadcaster: 'pusher',
  key: Laravel.keys.pusher(here says Uncaught ReferenceError: Laravel is not defined)
});

我在这个Laravel is not defined中尝试过解决方案,但它没有用......有什么想法吗?

0 个答案:

没有答案