Replies: 2 comments
-
Why not just support multiple components in a SFC file? In this way a main component and related components can be co-located and managed more easily and make use of compiler macros. I find the single component per file restriction strange. <component name="C1">
<script setup></script>
<template></template>
<style></style>
</component>
<component name="C2">
<script setup></script>
<template></template>
<style></style>
</component>
... then import {C1, C2} from "file1.vue" |
Beta Was this translation helpful? Give feedback.
-
Not official but we have https://vue-vine.dev ~ it's compatible with SFC and you can leverage more flexibility and write multiple components in one TS file. The Vue Vine toolchain is backed by Vue official members like @johnsoncodehk and more vue core members, if you meet any issue please report to https://github.com/vue-vine/vue-vine/issues ❤️ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Introduce a concise way to define local/micro components within another component file, without requiring JSX/TSX.
Basic example
Doesn't have to be exactly this, this is just a general idea of how it could be:
Motivation
Developers often encounter “micro-components” - Template code that are:
Currently the only way to achieve this is using JSX and h() calls
Detailed design
Here is an example of a practical use case of this feature. Let us assume we are creating a button with inline icon:
In this example, most of the code is duplicate but also:
This problem could be solved by defining micro-component locally within the file. The code would then look something like this:
Drawbacks
Alternatives
JSX and h() calls.
Adoption strategy
There will be no breaking changes. Developers can adopt to new or existing Vue 3 codebase without breaking anything.
Unresolved questions
Beta Was this translation helpful? Give feedback.
All reactions