[Vuejs]-Improvement on import … from

2👍

You can use re-export for that.

# file: @/theGoodPath
export { default as bar } from '@/components/chart/bar.vue'
export { default as dashboard } from '@/components/chart/dashboard.vue'
export { default as gantt } from '@/components/chart/gantt.vue'

Than usage will look like this:

<template>
  <!-- ... some code -->
</template>

<script>
import { bar } from '@/theGoodPath'

// ... some code, use `bar` here
</script>

Learn more about re-export here – http://jamesknelson.com/re-exporting-es6-modules/


Check live demo here

Leave a comment