Nuxt/examples/component-injection/pages/_slug.vue
2017-07-10 08:56:02 +02:00

19 lines
456 B
Vue

<template>
<component :is="comp"/>
</template>
<script>
const components = {}
const files = require.context('@/articles', false, /\.vue$/)
files.keys().forEach((filename) => {
const name = filename.replace('./', '').replace('.vue', '')
components[name] = () => import('@/articles/' + name + '.vue').then((m) => m.default || m)
})
export default {
async asyncData({ params, error }) {
return { comp: params.slug }
},
components
}
</script>