Skip to content

Instantly share code, notes, and snippets.

@sumbad
Created April 14, 2017 17:15
Show Gist options
  • Save sumbad/b8f682341afaf53cb30e08183f4480fa to your computer and use it in GitHub Desktop.
Save sumbad/b8f682341afaf53cb30e08183f4480fa to your computer and use it in GitHub Desktop.
Использование Vue.js для создания пользовательских Web компонентов
<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