4
This is the structure of my project:
As you can see in the image above the app.js file is in the folder Assets/js
my app.js file looks like this;
//var urlUsers = 'https://randomuser.me/api/?results=10';
var urlUsers = 'https://jsonplaceholder.typicode.com/users';
new Vue({
el: '#main',
created: function() {
this.getUsers();
},
data: {
lists: []
},
methods: {
getUsers: function() {
axios.get(urlUsers).then(response => {
this.lists = response.data
});
}
}
});
The file to configure the Javascript files in the Laravel project is the webpack.mix.js
He’s like this;
let mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js([
'resources/assets/js/vue.js',
'resources/assets/js/axios.js',
'resources/assets/js/app.js',
], 'public/css/app.js');
And the main page is like this;
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel e Vue</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div id="main" class="container">
<div class="row">
<div class="col-sm-4">
<h1>VUEjs - AJAX axios</h1>
<ul class="list-group">
<li v-for="item in lists" class="list-group-item">
@{{ item.name }}
</li>
</ul>
</div>
<div class="col-sm-8">
<h1>JSON</h1>
<pre>
@{{ $data }}
</pre>
</div>
</div>
</div>
<script type="text/javascript" src="{{ elixir('js/app.js') }}"> </script>
</body>
</html>
My browser was to appear like this;
but it’s showing up like this;
Why is my project not recognizing the Javascript files or is it because the app.js file is programming logic error?
================================================================
This is my repository:
Click here to access the repository
This is the image that appears in the Powershell console log
And I’m following this course here on youtube.
Click here to see the video lesson.
======================================================
is generating this error;
PS C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud> php artisan clear-compiled
PHP Warning: require(C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\wladimi
r\Desktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
Warning: require(C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\wladimir\Des
ktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
PHP Fatal error: require(): Failed opening required 'C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in
C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
Fatal error: require(): Failed opening required 'C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\U
sers\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
PS C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud> php artisan serve
PHP Warning: require(C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\wladimi
r\Desktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
Warning: require(C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\wladimir\Des
ktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
PHP Fatal error: require(): Failed opening required 'C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in
C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
Fatal error: require(): Failed opening required 'C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\U
sers\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud\artisan on line 18
PS C:\Users\wladimir\Desktop\php\laravel-vue-crud-master\laravel-vue-crud>
You have some error in the console?
– Sergio
Where the client’s root/public folder is closed in Laravel?
– Sergio
No error messages appear on the Google Chrome console, the folder is set to be the Assets/js I want to apologize if suddenly my answer is not compatible with the question, it is because I started studying PHP Laravel a little while ago.
– wladyband
Please preview my post again as I’ve made updates.
– wladyband