Last active
November 11, 2019 22:05
-
-
Save zwacky/ad1e2adf48badc7fbaba56a8248f6563 to your computer and use it in GitHub Desktop.
How to let the functional component inherit properties like "class"
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
// creating our functional component | |
<script lang="tsx"> | |
Vue.component('MyFunctionalComponent', { | |
functional: true, | |
render: (h: CreateElement, ctx: RenderContext<any>) => { | |
return <img {...ctx.data} /> | |
} | |
} | |
</script> | |
// now this: | |
<MyFunctionalComponent src="…" class="img-responsive" alt="my fc" /> | |
// will turn into: | |
<img src="…" class="img-responsive" alt="my fc" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment