Skip to content

Instantly share code, notes, and snippets.

@nabrown
Created July 27, 2018 22:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabrown/3ff0a13acf365d7d725a44589d197017 to your computer and use it in GitHub Desktop.
Save nabrown/3ff0a13acf365d7d725a44589d197017 to your computer and use it in GitHub Desktop.
Standard component using a render function
export default {
props: {
src: {
required: true,
type: String
},
type: {
required: true,
type: String
},
tags: {
required: false,
type: Array
}
},
render(createElement){
const img = createElement(
'img',
{
'attrs': {
'src': this.src
}
}
)
const caption = this.$slots.default ? createElement(
'figcaption',
[ createElement('span', this.$slots.default) ]
) : ''
const tags = this.tags && (this.type != 'framed') ? createElement(
'div',
{'class' : 'tags'},
this.tags.map(function (tag) {
return createElement('span', tag)
})
) : ''
return createElement(
'figure',
{
'class': this.type,
'on': {
'click' : () => {
this.$emit('click')
}
}
},
[img, caption, tags]
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment