A
A
Alianos2021-03-22 19:56:44
Vue.js
Alianos, 2021-03-22 19:56:44

What does defineComponent mean?

When executing the vue add i18n command in vue cli, after creating the project, a file from i18n will appear with this markup

<template>
  <p>{{ $t("hello") }}</p>
</template>

<script>
import { defineComponent } from "vue";

export default defineComponent({
  name: "HelloI18n",
});
</script>

<i18n>
{
  "en": {
    "hello": "Hello i18n in SFC!",
  },
}
</i18n>

What is defineComponent here and what is it for?
Why export default defineComponent and not just export default?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-03-22
@Alianos

https://v3.vuejs.org/api/global-api.html#definecom...
Free translation:
The function does nothing, only returns the passed object.
Needed to support TypeScript and IDE (autocomplete, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question