繁体   English   中英

在laravel刀片文件中,当我添加新的代码行一段时间后,javascript停止工作

[英]In laravel blade file javascript stops working after some time when i add new line of code

首先是javascript iam的新iam从3个星期开始面临此问题,并尝试对其进行调试,但未找到任何解决方案,因此问题是,当我在刀片文件中编写了一段新的js代码时,此后5-10分钟工作正常没有响应,控制台甚至不显示任何js错误

我还使用了以下命令php artisan cache:clear php artisan view:clear什么都没有发生,然后我创建了一个新的laravel项目,其版本为5.8,并尝试在其中进行同样的操作,但是在它的工作原理不错,但是在我的旧项目中却不行,然后我升级了它版本相同的问题,然后我将所有文件从旧项目移至新创建的项目,然后javascript正常运行,一段时间后,同一问题开始,然后我意识到在代码中添加新的代码段会导致当我删除新行时代码无法正常工作代码可以正常工作,当我添加var info = {!! json_encode($pdata->toArray()) !!}; var info = {!! json_encode($pdata->toArray()) !!}; 它可以正常工作一段时间,然后整个js代码停止工作,然后我删除此行代码,再次开始工作

   <script>
    var button=document.getElementById('claps');
    var not_span=document.getElementById('notifications');
    var not_butn=document.getElementById("notification-btn" );
    var message=document.getElementById('message');
    var trash =document.getElementById('trash');
    var info = {!! json_encode($pdata->toArray()) !!};
    var jsoninf=JSON.stringfy(info);
    count1=0;
    count2=0; 
    button.onclick=function()
    {
      count1=count1+1;
      button.innerHTML=count1;

    //   not_span.innerHTML="*"+count1;

      message.innerHTML=jsoninf + " Claped on your post";
    }

    button.onmouseover=function()
    {
      button.innerHTML=count1;
    }
    button.onmouseout=function()
    {
      button.innerHTML='<img src="https://img.icons8.com/color/30/000000/applause.png">'+'Claps';
    }
    not_butn.onclick=function()
    {
      not_span.style.display='none';
    }
    trash.onclick=function()
    {
      count2=count2+1;

      trash.innerHTML=count2;

       //not_span.innerHTML=count2;

      message.innerHTML="Abubakar" + "Trashed you post";
    }
    trash.onmouseover=function ()
    {
      trash.innerHTML=count2;
    }

    trash.onmouseout=function ()
    {
      trash.innerHTML='<img src="https://img.icons8.com/color/30/000000/delete.png">'+" Trash";
    }


  </script>

我的chrome控制台中没有与js代码相关的错误

此代码将在刀片服务器中执行

var info = @json($pdata->toArray());
// var jsoninf=JSON.stringfy(info); // remove this

info变量将成为javascript对象/数组。 您不需要解析它,刀片将以这种方式为您完成工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM