Functional Component
What problem does this feature solve?
the Vue script only exports an function. This is a syntactic sugar for the setup method, like Function component for React render methods;
Before syntax:
<template>
<div>{{title}}</div>
</template>
<script lang="ts">
import { ref } from 'vue';
export default {
setup(props) {
const title = ref('Hello World');
return { title };
}
}
</script>
After syntax:
<template>
<div>{{title}}</div>
</template>
<script lang="ts">
import { ref } from 'vue';
export default (props) => {
const title = ref('Hello World');
return { title };
}
</script>
What does the proposed API look like?
pure functional component