简体   繁体   English

Vue 在 Laravel Spark Blade 模板中包含两次 Javascript 文件

[英]Vue including Javascript files twice in Laravel Spark Blade template

I'm new to Laravel Spark and Vue, and have tried to move an existing app to it.我是 Laravel Spark 和 Vue 的新手,并尝试将现有应用程序迁移到它。 In that app, I have these scripts included in the Blade template, which is then injected into app.blade.php:在该应用程序中,我将这些脚本包含在 Blade 模板中,然后将其注入 app.blade.php:

<script type="application/javascript" src="{{ mix('js/sidebar.js') }}"></script>
<script type="application/javascript" src="{{ mix('js/addEditTask.js') }}"></script>
<script type="application/javascript" src="{{ mix('js/scheduler.js') }}"></script>

The problem is that functions from inside these files are getting called twice.问题是这些文件中的函数被调用了两次。 How can I fix this?我怎样才能解决这个问题?

函数调用

I ended up adding a stack to the bottom of my app.blade.php, so it looks like this:我最终在 app.blade.php 的底部添加了一个堆栈,所以它看起来像这样:

<!-- JavaScript -->
@stack('scripts-bottom')
<script src="{{ mix('js/app.js') }}"></script>

Then in my other blade file, I push them onto the stack:然后在我的另一个刀片文件中,我将它们推入堆栈:

@push('scripts-bottom')
<script type="application/javascript" src="{{ asset('js/sidebar.js') }}"></script>
<script type="application/javascript" src="{{ asset('js/addEditTask.js') }}"></script>
<script type="application/javascript" src="{{ asset('js/scheduler.js') }}"></script>
@endpush

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

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