我是Laravel的新手,我正在尝试让Telescope在我的项目中工作。当我试图在Chrome上导航到Localhost:8000/telescope时,我得到一个空白页面。我追踪到了laravel/telescope/resources/views/layout.blade.php.的错误
<!-- Global Telescope Object -->
<script>
window.Telescope = @json($telescopeScriptVariables);
</script>我得到的开发人员控制台错误:
window.Telescope
= {"path":"telescope","timezone":"UTC","recording":true};我主要关心的是找到一个解决方案。我也想知道为什么会发生这个错误。我在谷歌上找不到类似的问题。
发布于 2020-03-17 09:34:30
经过进一步的谷歌搜索,我找到了原因和解决方案。在Laravel和Vue上发现了一个非常类似问题的here in this article。
通过双重编码,JSON对象将从对象中删除HTML实体。建议在AppServiceProvider中设置刀片双编码。
class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Blade::doubleEncode(); } }
我使用的另一个解决方案是在layout.blade.php中进行双重内联编码。
<!-- Global Telescope Object -->
<script>
window.Telescope = {!!json_encode($telescopeScriptVariables)!!}
// window.Telescope = @json($telescopeScriptVariables);
</script>https://stackoverflow.com/questions/60662149
复制相似问题