I am using Laravel 10, Vite and Vue
I want to use two component inside my App.vue
Here is my App.vue file :
<template>
<div>
<AppHeader></AppHeader>
... Content ...
<AppFooter></AppFooter>
</div>
</template>
<script setup>
import AppHeader from "./components/partials/AppHeader.vue";
import AppFooter from "./components/partials/AppFooter.vue";
export default {
components : {
AppHeader,
AppFooter,
}
}
</script>
I get this error :
[vite:vue] [@vue/compiler-sfc] <script setup> cannot contain ES module exports. If you are using a previous version of <script setup>, please consult the updated RFC at https://github.com/vuej
s/rfcs/pull/227.
C:/xampp/htdocs/laravel/rest_api/resources/js/components/App.vue
9 | <script setup>
10 | import AppHeader from "./components/partials/AppHeader.vue";
11 | import AppFooter from "./components/partials/AppFooter.vue";
| ^
12 | export default {
| ^^^^^^^^^^^^^^^^
13 | components : {
| ^^^^^^^^^^^^^^^^^^
14 | AppHeader,
| ^^^^^^^^^^^^^^^^^^
15 | AppFooter,
| ^^^^^^^^^^^^^^^^^^
16 | }
| ^^^^^
17 | }
| ^
Thanks
I am a total beginner in Vue and this code is from a Tutorial
2
Answers
Thanks your help works for me but I changed
to
the script setup has changed with the introduction of new syntax in Vue 3.1. According to the problem message, "script setup" cannot include exports of ES modules.
Removed the export default statement inside .
You no longer need to use export default in the syntax. The essential variables and parts are implicitly exported by the setup block.
Used defineProps to handle props if you have any.
You must use the defineProps function to explicitly define any props your component may have. By doing this, you can be sure that your component can manage and access the props properly.
The setup section declares the components, and those components are immediately usable in the template.So you don’t need to export
AppHeader
andAppFooter
because you can use them directly in the template.