Home  >  Q&A  >  body text

View | module has no default export

I encountered an error in vue3, ts, vue cli, which shows Module '"c:/Users/USER/Documents/top-secret-project/src/components/Features/Features.vue"' has no default export. When importing components from a file I don't know why this particular component decided to work now.

This is Features.vue

<script lang="ts">
import Feature from "./Feature.vue";
</script>

<template>
  <Feature />
</template>


P粉011360903P粉011360903358 days ago742

reply all(2)I'll reply

  • P粉128563140

    P粉1285631402023-10-27 07:17:28

    @Boussadjra mentioned that this may happen if the Vetur extension is installed in Visual Studio Code. Insert Vetur This problem can be solved if we install the Volar extension in Visual Studio Code.

    reply
    0
  • P粉665679053

    P粉6656790532023-10-27 00:29:07

    Use script setup syntax, no need to add export default in the script, just add the setup attribute to the script:

    <script lang="ts" setup>
    import Feature from "./Feature.vue";
    </script>
    
    <template>
      <Feature />
    </template>
    

    reply
    0
  • Cancelreply