View | module has no default export
P粉011360903
P粉011360903 2023-10-26 09:06:56
0
2
805

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粉011360903
P粉011360903

reply all(2)
P粉128563140

@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.

P粉665679053

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>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template