R
R
Renhor2019-06-08 01:01:23
Vue.js
Renhor, 2019-06-08 01:01:23

Vue router in the finished site, how to set it up?

Good evening! I have a page on the site, for example:
sitename.ru/dash/vue.php
In fact, through .htaccess, the path looks like this:
sitename.ru/dash/vue
I want to practice using Vue on this page and, for example, I need it on this page navigation like
/dash/vue/home
/dash/vue/test
Tried:

const routes = [
  {
    path: '/dash/booster/',
    redirect: {
      name: 'home'
    }
  },
  {
    name: '/dash/booster/home',
    path: '/home',
    component: HomePage
  },
  {
    name: '/dash/booster/test',
    path: '/test',
    component: TestPage
  }
];

And
const routes = [
  {
    path: '/dash/vue/',
    redirect: {
      name: 'home'
    }
  },
  {
    name: '/dash/vue/home',
    path: '/home',
    component: HomePage
  },
  {
    name: '/dash/vue/test',
    path: '/test',
    component: TestPage
  }
];

Didn't work -_- What should I do? As I understand it, you need to register somewhere the root path of Vue-router?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2019-06-08
@Renhor

const router = new Router({
  mode: 'history',
  base: '/dash/vue/',
  routes: [{
    path: '/home',
    alias: '/',
    name: 'home'.
    component: HomePage
  }, {
    name: 'test',
    path: '/test',
    component: TestPage
  }]
})

the server, in turn, should :/dash/vue/**/*always giveindex.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question