+added VueRouter

This commit is contained in:
xdrm-brackets 2018-02-28 12:36:54 +01:00
parent 3e1ab4796c
commit 9543c7621c
7 changed files with 80 additions and 2 deletions

5
package-lock.json generated
View File

@ -8586,6 +8586,11 @@
}
}
},
"vue-router": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-2.8.1.tgz",
"integrity": "sha512-MC4jacHBhTPKtmcfzvaj2N7g6jgJ/Z/eIjZdt+yUaUOM1iKC0OUIlO/xCtz6OZFFTNUJs/1YNro2GN/lE+nOXA=="
},
"vue-style-loader": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-3.1.2.tgz",

View File

@ -17,7 +17,8 @@
"build": "npm run bundle:clean; npm run bundle:prod; npm run scss"
},
"dependencies": {
"vue": "^2.5.9"
"vue": "^2.5.9",
"vue-router": "^2.5.3"
},
"browserslist": [
"> 1%",

View File

@ -0,0 +1,21 @@
<template>
<div id='CONTAINER' class='page1'>
</div>
</template>
<script>
export default {
name: 'CONTAINER_PAGE1',
data(){
return { gstore: gstore.get }
}
}
</script>

View File

@ -0,0 +1,21 @@
<template>
<div id='CONTAINER' class='page2'>
</div>
</template>
<script>
export default {
name: 'CONTAINER_PAGE2',
data(){
return { gstore: gstore.get }
}
}
</script>

View File

@ -2,6 +2,8 @@
---------------------------------------------------------*/
/* (1) NPM libs */
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from '../routes/home'
/* (2) Vues */
import wrapper_vue from '../vue/wrapper.vue'
@ -15,9 +17,20 @@ require('../data/home');
/* (2) Initialisation
---------------------------------------------------------*/
/* (1) Render view */
/* (1) Init Router */
const router = new VueRouter({
mode: 'history',
routes: routes[0]
});
/* (2) Store router in gstore */
gstore.add('router', router);
/* (3) Render view */
Vue.use(VueRouter);
new Vue({
el: '#main-vue',
router,
render: h => h(wrapper_vue)
});

14
webpack/routes/home.js Normal file
View File

@ -0,0 +1,14 @@
export default{ 0: [
{
path: '/home/page1/',
component: require('../component/home/page1.vue').default
}, {
path: '/home/page2/',
component: require('../component/home/page2.vue').default
}, {
path: '*',
redirect: '/home/page1/'
}
]}

View File

@ -7,6 +7,9 @@
<!-- Menu -->
<menu-comp></menu-comp>
<!-- Container -->
<router-view></router-view>
</div>
</template>