Skip to content

Instantly share code, notes, and snippets.

@sumbad
sumbad / Vuejs-WebComponents.html
Last active April 13, 2017 13:27
Использование Vue.js для создания пользовательских Web компонентов
<div id="my-app">
<p>Introduction text</p>
<share-buttons/>
</div>
@sumbad
sumbad / share-buttons.html
Created April 13, 2017 13:33
Использование Vue.js для создания пользовательских Web компонентов
<div id="my-app">
<p>Introduction text</p>
<share-buttons>
<div id="share-buttons">
<a href="#">Facebook</a>
<a href="#">Twitter</a>
</div>
</share-buttons>
</div>
@sumbad
sumbad / theHTMLway.html
Created April 14, 2017 17:15
Использование 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>
@sumbad
sumbad / my-vue-componentHTML.html
Created April 15, 2017 04:35
Использование Vue.js для создания пользовательских Web компонентов
<html>
<body>
...
<my-vue-component/>
<!-- allows multiples instances of the same component -->
<my-vue-component my-prop="true"/>
class MyElement extends HTMLElement {
constructor() {
super();
this.msg = 'Hello, World!';
}
connectedCallback() {
this.innerHTML = `<p>${this.msg}</p>`;
}
<template id="share-buttons-template">
<div id="share-buttons">
<a href="#">Facebook</a>
<a href="#">Twitter</a>
</div>
</template>
<html>
<head>
<link rel="import" href="share-buttons.html">
...
</head>
<body>
...
<share-buttons></share-buttons>
...
</body>
<html>
<template>
<div id="share-buttons">
<a href="#">Facebook</a>
<a href="#">Twitter</a>
</div>
</template>
<script>
(function() {
...
this.dispatchEvent(new Event('content-shared'));
@sumbad
sumbad / custom-elements.html
Created July 3, 2017 15:36
webcomponents-base__custom-elements_1
<!DOCTYPE html>
<html>
<head>
<title>Custom Elements</title>
<script type="text/javascript">
class FirstCustomElement extends HTMLElement {
constructor() {
super();
console.log('constructor');
}