Created
May 4, 2017 07:51
-
-
Save vuejsdevelopers/501f5f8ab5392485e200382409e6463b to your computer and use it in GitHub Desktop.
7 Ways To Define A Component Template in Vue.js - Snippet 04
This file contains hidden or 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', { | |
data() { | |
return { | |
checked: false, | |
title: 'Check me' | |
} | |
}, | |
methods: { | |
check() { | |
this.checked = !this.checked; | |
} | |
} | |
}); |
This file contains hidden or 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
<my-checkbox inline-template> | |
<div class="checkbox-wrapper" @click="check"> | |
<div :class="{ checkbox: true, checked: checked }"></div> | |
<div class="title"></div> | |
</div> | |
</my-checkbox> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment