TaskList.vue file code Resoueces/assets/js/components
<template> <div> <ul> <li v-for="task in tasks" v-text="task"> </li> </ul> </div> </template> <script> export default { data() { return{ tasks: [] }; }, created(){ axios.get('/tasks').then(response => (this.tasks = response.data)); } }; </script> 2.App.js file code **Resources/assets/js** /** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); window.Vue = require('vue'); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ Vue.component('task-list', require('./components/TaskList.vue')); const app = new Vue({ el: '#app' }); 3. welcome.blade.php file code <body> <div id="app"> <task-list></task-list> </div> </body>
1)
[Vue warn]: Property or method "task" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
2)app.js:13797 GET http://localhost/tasks 404 (Not Found)
3) You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
4) app.js:13822 Uncaught (in promise) Error: Request failed with status code 404
at createError (app.js:13822)
at settle (app.js:35254)
at XMLHttpRequest.handleLoad (app.js:13696)
Route List: route/web.php
Route::get('/tasks', function () {
return Task::latest()->pluck('body');
});
Route::get('/tasks', function () {
Task::ForceCreate(request(['body']));
});
app.js:13797 GET http://localhost/tasks 404 (Not Found)
and problem 2 isapp.js:36520 [Vue warn]: Property or method "task" is not defined
Try reducing your code to a small subset, so every problem gets attention, you don't risk partial answers where the answers basicly address half of your issue, and then you get into trouble with properly selecting an accepted answer – Ferrybig