Skip to content

Is it possible to import from an ES6 module in a component (SFC) ? #14

@raphael-bresson

Description

@raphael-bresson

Hi,
First I wan't to thank you for this librairy which is going to be very useful for me.
I can't manage to import from a module inside a script tag of a .vue file
For example :

<template>
  <div class="test">Test</div>
</template>

<script>
import { label } from "./../tools.js";
export default {
  name: "appWorld",
  computed: {
    ...Vuex.mapState(["count"]),
  },
  mounted() {
    console.log(`Component ${this.$options.name} mounted - ${label}`);
  },
};
</script>

<style scoped>
div.test {
  color: red;
}
</style>

The line
_import { label } from "./../tools.js";_

raises the following error.

_'import' and 'export' may appear only with 'sourceType: "module"' (2:0)_

I tried adding type="module" to the script tag but it didn't work either.

Is it possible to do that ? How ?
Thank you for your answer

Raphael

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions