Last active
May 4, 2017 07:50
-
-
Save vuejsdevelopers/c1e5d430002b8867d7b47d144c9019ae to your computer and use it in GitHub Desktop.
7 Ways To Define A Component Template in Vue.js - Snippet 03
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
Vue.component('my-checkbox', { | |
template: '#checkbox-template', | |
data() { | |
return { | |
checked: false, | |
title: 'Check me' | |
} | |
}, | |
methods: { | |
check() { | |
this.checked = !this.checked; | |
} | |
} | |
}); |
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 type="text/x-template" id="checkbox-template"> | |
<div class="checkbox-wrapper" @click="check"> | |
<div :class="{ checkbox: true, checked: checked }"></div> | |
<div class="title"></div> | |
</div> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment