我得到了我的档案main.js,我把档案放在template.blade.php中,我把pusher.js放在模板中:
<script src="http://js.pusher.com/3.1/pusher.min.js"></script>
我的main.js:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$(document).mouseup(function(e)
{
var container = $(".to-hide");
var container2 = $(".to-close");
if ($(".no-close").length){
} else {
if (!container.is(e.target) && container.has(e.target).length === 0)
{
container.hide();
}
if (!container2.is(e.target) && container2.has(e.target).length === 0)
{
container2.remove();
}
}
});
//import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'MY-KEY'
});
当我删除// import的注释时... jquery不起作用,并且不导入echo,为什么?
控制台错误:
Uncaught SyntaxError: Unexpected identifier