Unable to achieve path jump of vue-router
P粉101708623
P粉101708623 2023-08-30 15:16:18
0
1
367

So when I'm on the home page (http://127.0.0.1:8000/) I get the correct components I set in the vue-router file, but whenever I go to http://127.0 .0.1:8000/dashboard, it shows me a 404 error and I really don't know why. The path to the component is correct

This is my vue-router file:

import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) import loginPage from '../Pages/loginPage' import dashboard from '../Pages/dashboard' const router = new VueRouter({ mode: 'history', routes: [ { path: '/', name: 'login', component: loginPage }, { path: '/dashboard', name: 'dashboard', component: dashboard, }, ], }); export default router;

This is my app.js file

import Vue from 'vue'; import index from './Index.vue' import VueRouter from 'vue-router' Vue.use(VueRouter) import router from './router'; import axios from 'axios'; import VueAxios from 'vue-axios'; window.Vue = require('vue').default; newVue({ router, render: h => h(index), }).$mount('#app')

This is the index.vue file (where I display the component when the link changes)

 
P粉101708623
P粉101708623

reply all (1)
P粉834840856

If you are using Laravel Vue, you must check if you are passing the route

Route::get('/{any}', function () { return view('welcome'); })->where('any','.*')->name('vue')
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!