Comments (7)
@javialon26 Sorry I forgot something, try with:
import Router from 'vue-router'
// import HomePage from '@/components/pages/index.vue'
const HomePage = () => import('@/components/pages/index.vue').then(m => m.default || m)
const HelpPage = () => import('@/components/pages/ayuda.vue').then(m => m.default || m)
Vue.use(Router)
export function createRouter () {
return new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: HomePage
},
{
path: '/ayuda',
name: 'ayuda',
component: HelpPage
}
]
})
}
from router-module.
Ran into the same issue when attempting to customize code-splitting. Can confirm that the solution provided by @Atinux (.then(m => m.default || m)
) works!
from router-module.
Should this be documented somewhere in the doc ?
I had a (probably) the same issue but with a slightly different error message and @Atinux solution solved it.
render function or template not defined in component: anonymous
from router-module.
Hi @javialon26
Actually no, you have to do it manually, example:
import Vue from 'vue'
import Router from 'vue-router'
// lazy load the pages
const MyPage = () => import('~/components/my-page')
Vue.use(Router)
export function createRouter() {
return new Router({
mode: 'history',
routes: [
{
path: '/',
component: MyPage
}
]
})
}
from router-module.
@Atinux i have an error with this config:
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
found in
--->
at .nuxt/components/nuxt.vue
at layouts/default.vue
[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside
, or missing . Bailing hydration and performing full client-side render.
this is my router.js
import Router from 'vue-router'
// import HomePage from '@/components/pages/index.vue'
const HomePage = () => import('@/components/pages/index.vue')
const HelpPage = () => import('@/components/pages/ayuda.vue')
Vue.use(Router)
export function createRouter () {
return new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: HomePage
},
{
path: '/ayuda',
name: 'ayuda',
component: HelpPage
}
]
})
}
thank you
from router-module.
@Atinux work like a charm, thank you!
from router-module.
This question has been resolved by @Atinux, see answer.
from router-module.
Related Issues (20)
- base route is appended to url on page referesh HOT 1
- next() function is not working well HOT 1
- children in route.js don't work HOT 2
- Custom router in .nuxt folder HOT 2
- does it support nuxt3 with vue3 HOT 3
- Vue router 4 support HOT 6
- Release HOT 1
- Cannot start nuxt: Cannot find module 'nuxt/lib/app/router' in nuxt3 HOT 5
- Readme "If you are using Nuxt < 2.16.0, the parameter store is not available" HOT 2
- the css load order changes after using @nuxtjs/router
- Cannot extend routes from a module
- Code splitting not working with router.js HOT 3
- `Cannot read properties of undefined (reading 'options')` on add @nuxtjs/router to Nuxt 3 project HOT 1
- Docs: Missing correct docs about the `store` parameter.
- Can I access to the routes within another module?
- Anchor link dont work on yarn generate
- Is this module compatible with SSG build?
- Nuxt 3 Support HOT 1
- Nuxt content not generate or parse to custom router
- Hydratation error with SSG HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router-module.