I’m trying to use native vue-router but it’s not working yet.
Ref project: https://github.com/aadamsx/fp-admin
I’m getting the following error:
Uncaught TypeError: Router.map is not a function
Here is the code:
// router.js
// import { Router } from 'meteor/akryum:vue-router2';
import Router from 'vue-router'
import Index from '/imports/client/views/public/Index.vue';
import Page from '/imports/client/views/public/Page.vue';
import FirstForm from '/imports/client/views/public/FirstForm.vue';
// Not found
import NotFound from '/imports/client/views/public/NotFound.vue';
Router.map({
// Not found handler
'*': {
component: {
template:
'<div>' +
'<h1>Not Found</h1>' +
'</div>'
}
},
'/': {
component: Index
},
'/page': {
component: Page
},
'/first-form': {
component: FirstForm
},
'/not-found': {
component: NotFound
}
});
And code from Meteor.startup:
// app.js
import '/imports/client/router.js';
import Vue from 'vue';
import VueMeteorTracker from 'vue-meteor-tracker'
// import { Router, nativeScrollBehavior } from 'meteor/akryum:vue-router2';
import Router from 'vue-router'
import AppLayout from '/imports/client/views/AppLayout.vue';
const router = new Router({
mode: 'history',
scrollBehavior: nativeScrollBehavior,
});
Meteor.startup(() => {
Vue.use(VueMeteorTracker);
Vue.use(Router);
new Vue({
router: router.start(),
render: h => h(AppLayout),
}).$mount('app');
});
My original code that used akryum:vue-router2 worked fine and looked like this:
import { Router } from 'meteor/akryum:vue-router2';
import Index from '/imports/client/views/public/Index.vue';
import Page from '/imports/client/views/public/Page.vue';
import FirstForm from '/imports/client/views/public/FirstForm.vue';
// Not found
import NotFound from '/imports/client/views/public/NotFound.vue';
Router.configure(router => {
router.addRoutes([{
path: "/",
name: "Index",
components: {
default: Index,
}
}, {
path: "/page",
name: "Page",
components: {
default: Page,
}
}, {
path: "/first-form",
name: "FirstForm",
components: {
default: FirstForm,
}
}, {
path: "/not-found",
name: "NotFound",
components: {
default: NotFound,
}
},]);
});