main.js:
import Vue from 'vue';
import App from './App';
import router from './routes/Route';
Vue.config.productionTip = false;
new Vue({
el: '#app',
render: h => h(App),
router
})
Route.js:
import Vue from "vue";
import VueRouter from "vue-router";
import Routes from "./Routes";
Vue.use(VueRouter);
export default new VueRouter({
mode: 'history',
Routes
});
Routes.js:
import About from '../components/About';
import Work from '../components/Work';
import Contact from '../components/Contact';
export default [
{
path: '/about',
name: 'about',
component: About
}
]
Menu.vue:
<template>
<div class="menu-top">
<router-link class="menu-href-route" to="/about"><span>About</span></router-link>
</div>
</template>
<script>
export default {
name: 'Menu',
}
</script>
Hello.vue:
<template>
<div class="hello">
<router-view></router-view>
</div>
</template>
<script>
import About from './About';
export default {
name: "Hello"
}
</script>
About.vue:
<template>
<div>
About test text
</div>
</template>
<script>
export default {
name: "about"
}
</script>
I create in file Route.js routing and export him to main.js. Next in file Routes.js I create path to componentns. In file Menu.js is router-link. And file Hello.vue have router-view. About.vue is view component. I don't know why component About.vue is not loading in file Hello.vue, when I have address: http://localhost:8080/about
. I reinstall node and vue-router, but this not helping.