【发布时间】:2018-12-25 16:02:15
【问题描述】:
首先感谢您的阅读。让我解释一下我面临的问题。所以我成功安装了 Pusher 和 Laravel Echo 并尝试在我的dash.blade.php 中使用它,这就是我导入app.js 文件的方式:<script src="{{ asset('js/app')}}"></script>。之后我用了这个:
<script>
Echo.channel('channelDemoEvent')
.listen('eventTrigger', (e) => {
alert('Its working');
});
</script>
运行它时,我在 chrome 控制台中收到此错误:Uncaught ReferenceError: Echo is not defined
我在互联网上搜索了这个错误超过 2 小时,当我在 Echo 之前添加 window. 时,我得到了一个不同的错误,那个错误是这样的:
Uncaught TypeError: Cannot read property 'channel' of undefined
我试图在app.js 上评论这些,因为我读到这可能会导致此错误:Vue.component('example-component', require('./components/ExampleComponent.vue'));
window.Vue = require('vue');
const app = new Vue({
el: '#app',
});`
在评论那些我得到同样的错误之后。 感谢您的阅读,祝您有美好的一天。
【问题讨论】: