Nuxt/examples/component-injection/pages/_slug.vue

16 lines
333 B
Vue
Raw Normal View History

<template>
<BlogArticle/>
</template>
<script>
export default {
async asyncData({ params, error }) {
const slug = params.slug || 'hello'
try {
this.components.BlogArticle = await import(`~/articles/${slug}.vue`)
} catch (e) {
error({ statusCode: 404, message: 'Article not found' })
}
}
}
</script>