[Vuejs]-How to put JavaScript in Laravel make:auth

1👍

You’re trying to add a <script> to your blade @section, which is why you’re getting that error. There are a few ways to do this.

1.. Add your script tags to views/layouts/app.blade.php right before the </body> tag, for example:

<script></script>
</body>
</html>

2.. Place them in your <head> tag and add the defer attribute

<script defer></script>

Your register.blade.php and any other view that extends app.blade.php will now have access to these scripts because it extends the app.blade.php layout.

3.. Use the Blade @stack directive to push your script to a stack. Stacks can be named, in this example lets simply use the name scripts. Add this to register.blade.php

@push('scripts')
<script></script> <!-- Add your JS file or JS code -->
@endpush`

Now in the <head> tag of your app.blade.php you can place @stack('scripts')

Note: Only register.blade.php will load this script, any other view that extends app.blade.php will not have access to it.

👤Nathan

Leave a comment