Currently I am delving into the realm of Vue.js paired with Laravel by following this series, where the narrator seems to breeze through without encountering any errors. Unfortunately, when I attempted to change the route, a pesky error made an appearance.
[Vue warn]: Failed to mount component: template or render function not defined.
The section below showcases code snippets from my app.js
:
require('./bootstrap');
window.Vue = require('vue');
import VueRouter from 'vue-router'
Vue.use(VueRouter)
let routes = [{
path: '/dashboard',
component: require('./components/Dashboard.vue')
},
{
path: '/profile',
component: require('./components/Profile.vue')
}
]
const router = new VueRouter({
routes
})
Vue.component('example-component', require('./components/ExampleComponent.vue'));
const app = new Vue({
el: '#app',
router
});
In addition, here's a snippet of code extracted from my Dashboard.vue
:
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Dashboard Component</div>
<div class="card-body">
I'm an example component.
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
Lastly, here's a code excerpt from my master.blade.php
layout:
//sidebar
<ul>
<li>
<router-link to="/dashboard" class="nav-link">Dashboard</li>
<li>
<router-link to="/profile" class="nav-link">Profile</li>
</ul>
//content
<div class="container-fluid">
<router-view></router-view>
</div>
To run the app, I am utilizing localhost:3000
with some assistance from browserSync
and npm run watch
. Could this setup be contributing to the occurrence of the error?