Answer the question
In order to leave comments, you need to log in
How to call asyncData on an imported file?
Pages
directory structure :
contacts.vue
index.vue
landing.vue
//index.vue
<contacts v-if="show === 'contacts'"></contacts>
<landing v-else></landing>
import contacts from './contacts';
import landing from './landing';
...
asyncData() {
let show = 'landing';
if (someCondition) {
show = 'contacts';
}
return {show};
}
import contacts from '~/components/contacts';
import landing from '~/components/landing';
routes: [
{path: '/', name: 'Home', component: (someCondition ? contacts : landing)},
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question