Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use js in Laravel

I just want an alert to work and then I will go on my own, but when I write alert() in my recources/js/app.js it doesn't work, but my scss works, I ran npm run watch doesn't help, what to do, and why I can't find any information on google on just how to use js on laravel? :/

my mix file mix

my js file js

like image 435
Altro Avatar asked Sep 20 '25 04:09

Altro


1 Answers

Mix is just compiling the files, they aren't automatically injected into your blade files. Just take a look at your blade file, you should see something like

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

and

<link href="{{ asset('css/app.css') }}" rel="stylesheet">
like image 94
Second2None Avatar answered Sep 21 '25 21:09

Second2None