I get the same error and am trying to find a solution... will let you know if I find anything.
Any help from others?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Currently i am building a Vue2 APP and i am wondering how i can swap out my routes to a separate File.
So this is a bit of my bootstrap.js
const routes = [
{
path: '/hosting',
component: require('./components/support/index.vue'),
},
.....
.....
]
const router = new VueRouter({
routes // short for routes: routes
})
const App = Vue.extend(require('./backend.vue'))
const app = new Vue({
router,
render: h => h(App),
}).$mount('#app')
If i make a separate File with the Routes, for example a routes.js with its content
const routes = [
{
path: '/hosting',
component: require('./components/support/index.vue'),
},
.....
.....
]
How would i swap out this to a separate file? I tried it like so bootstrap.js
import routes from './routes'
...
Vue.use(VueRouter);
const router = new VueRouter({
routes
})
...
And my routes.js file
module.exports = {
routes: function () {
routes = [
{
path: '/support',
component: require('./components/support/index.vue'),
},
]
}
}
But i am just getting the error message Uncaught TypeError: routes.forEach is not a function . Can someone give a little tip? :)
Please or to participate in this conversation.