I would like to migrate my Vue 2 functional component to Vue 3. I read their official docs but don't understand it.
I have for example this component:
module.exports = (name, path, ariaLabel) => `<template functional>
<div
:class="['main-${name}', props.width ? 'default-width' : undefined]"
>
<span v-if="title">${title}</span>
<span> hello </span>
</div>
</template>
<script>
export default {
name: 'test-${name}',
props: {
width: {
type: [Number, String],
default: null
},
title: {
type: String,
required: false
},
}
}
</script>
<style src="./style.css"/>
`
I got this far converting to Vue 3:
import { h } from 'vue'
const MyComponent = (props, context) => {
return h(`div${props.name}`, context.attrs, context.slots)
}
MyComponent.props = {
width: {
type: [Number, String],
default: null
},
title: {
type: String,
required: false
},
}
import styles from './style.css';
export default MyComponent;
How do I properly import CSS? How would I add the nested span and the classes?