As per the official documentation,
defineProps
anddefineEmits
are compiler macros only usable inside<script setup>
. They do not need to be imported and are compiled away when<script setup>
is processed.
The problem definition
I'm not able to use defineProps
and defineEmits
in <script setup>
without importing it. Please refer to the error screenshot attached below.
The vue code which I'm executing
<!-- HelloWorld.vue -->
<template>
<h1>{{ props.message }}</h1>
</template>
<script setup>
// import { defineProps } from 'vue';
const props = defineProps({
message: {
type: String,
required: true,
}
});
</script>
The environment details for reference:
vue | ^3.2.6 (3.2.19) |
---|---|
vue-cli | @vue/cli 5.0.0-beta.4 |
node: | v14.16.1 |
npm | 6.14.12 |
module.exports = { env: { 'vue/setup-compiler-macros': true } }
– Nightrider