Where to add Javascritp/JQuery in laravel 7?

Viewed 1089

I am new to laravel. I have setup a project with Vue and tried to add jquery code in one of the blade page but I am seeing following error in console. Jquery is working fine but the error in console tells that I am not doing it the right way.

Vue warn]: Error compiling template:

Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as , as they will not be parsed.

331|
332|
333| | ^^^^^^^^ 334| function refresh(value) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 335| { | ^^^^^^^^^ 336| location.replace('jiras?status='+value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 337| }

Can anyone help me that where should I add jquery/javascript code so that it doesn't show any error in the console.

2 Answers
@extends('layout.app')

@section('content')

    <your-vue-component></your-vue-component>

@endsection

and inside layout/app.blade.php you can put jquery. Probably above the app.js file

Thank you for your answer Daud.

I created a jquery.js file and added my code inside it. I put this file under public/js/ directory and add the path of it inside app.blade.php file as follows:

<script src="{{ asset('js/jquery.js') }}" defer></script>

The jquery worked fine console error is also gone. Thank you for your help.

Related