Last active
September 22, 2023 04:43
-
-
Save megurock/25e7aca0e189f76cf833c9f700973396 to your computer and use it in GitHub Desktop.
slot に対する変更(script setup を使わない)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { mergeProps } from 'vue' | |
export default { | |
setup(props, context) { | |
const slotContent = context.slots?.default?.() | |
if (slotContent) { | |
slotContent.forEach(vNode => { | |
vNode.props.class = (vNode.props.class ?? '') + ' foo' | |
vNode.props.style = mergeProps(vNode.props.style, style) | |
}) | |
} | |
return () => slotContent ?? null | |
} | |
} | |
</script> | |
<template> | |
{{ render }} | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<script setup>
の場合