0👍
The reason why it wasn’t working is because of the way the const
was named in the new_route_list.js
file. You have to name it routes
since it is short for
new VueRouter({
routes: [
///routes here
],
mode:'history'
});
This is shown in this example here:
https://router.vuejs.org/guide/#javascript
Another thing I noticed was the AdminMaster.vue
file. It feels redundant, so I would recommend removing it and just do this in your admin_master.blade.php
:
<!-- Main content -->
<router-view></router-view>
<!-- /.content -->
Edit: Your files will need to be updated for this change
Here is app.js
:
require('./bootstrap');
window.Vue = require('vue');
import VueRouter from 'vue-router'
import { routes } from './new_route_list.js'
Vue.use(VueRouter)
const router = new VueRouter({
routes,
mode:'history'
});
const app = new Vue({
router
}).$mount("#app");
I updated the new Vue()
with .$mount()
and removed el:'#app'
per the the example shown in the link above.
Here is the update to new_route_list.js
:
import adminHome from './AdminHome.vue';
export const routes = [
{
path:'/',
component: adminHome
}
]
Update AdminHome.vue
too. You need to wrap the template in the closing </template>
tag and then you need to have script tags that export the component like shown below:
<template>
<div>
<!-- Main content -->
<section class="content">
<div class="card">
<div class="card-header">
<h3 class="card-title">Title</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i></button>
</div>
</div>
<div class="card-body">
Start creating your amazing application .....!
</div>
<div class="card-footer">
Footer
</div>
<!-- /.card-footer-->
</div>
</section>
<!-- /.content -->
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
- [Vuejs]-How to import & use @Google/maps npm package in Nuxt?
- [Vuejs]-Uncaught TypeError: [] is not a function