Skip to content

Instantly share code, notes, and snippets.

@zwacky
Last active November 11, 2019 22:05
Show Gist options
  • Save zwacky/ad1e2adf48badc7fbaba56a8248f6563 to your computer and use it in GitHub Desktop.
Save zwacky/ad1e2adf48badc7fbaba56a8248f6563 to your computer and use it in GitHub Desktop.
How to let the functional component inherit properties like "class"
// 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