Skip to content

Instantly share code, notes, and snippets.

@vuejsdevelopers
Created May 4, 2017 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vuejsdevelopers/2ee0abd9a7923e93a257fbae1f240bfd to your computer and use it in GitHub Desktop.
Save vuejsdevelopers/2ee0abd9a7923e93a257fbae1f240bfd to your computer and use it in GitHub Desktop.
7 Ways To Define A Component Template in Vue.js - Snippet 05
Vue.component('my-checkbox', {
data() {
return {
checked: false,
title: 'Check me'
}
},
methods: {
check() {
this.checked = !this.checked;
}
},
render(createElement) {
return createElement(
'div', {
attrs: {
'class': 'checkbox-wrapper'
},
on: {
click: this.check
}
}, [
createElement(
'div', {
'class': {
checkbox: true,
checked: this.checked
}
}
),
createElement(
'div', {
attrs: {
'class': 'title'
}
}, [this.title]
)
]
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment