Created
April 14, 2017 17:15
-
-
Save sumbad/b8f682341afaf53cb30e08183f4480fa to your computer and use it in GitHub Desktop.
Использование Vue.js для создания пользовательских Web компонентов
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
<div id="my-app"> | |
<p>Introduction text</p> | |
<share-buttons gplus="false"/> | |
</div> | |
<template id="share-buttons-template"> | |
<div id="share-buttons"> | |
<a href="#" @click.prevent="share" v-if="facebook">Facebook</a> | |
<a href="#" @click.prevent="share" v-if="twitter">Twitter</a> | |
<a href="#" @click.prevent="share" v-if="gplus">Google+</a> | |
</div> | |
</template> | |
<script src="vue.min.js"></script> | |
<script src="vue-custom-element.min.js"></script> | |
<script> | |
Vue.customElement('share-buttons', { | |
template: '#share-buttons-template', | |
props: { | |
facebook: { type: Boolean, default: true }, | |
twitter: { type: Boolean, default: true }, | |
gplus: { type: Boolean, default: true } | |
}, | |
methods: { | |
share ($event) { | |
window.alert('Share on ' + $event.target.innerHTML); | |
} | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment