JSFiddle - React, Tailwind, and code Playground
by Alex Babakhanov
HTML
<script src='https://unpkg.com/[email protected]/dist/vue.js'></script>
<div id='app'>
{{simpleString}}
</div>
<hr />
<div id='app2'>
{{simpleString}}
</div>
<hr />
<input onchange="eventBus.$emit('stringUpdated', this.value)"/>
JavaScript
window.eventBus = new Vue();
new Vue({
el: '#app',
data: {
simpleString: ''
},
created () {
var self = this;
eventBus.$on('stringUpdated', function(string){
self.simpleString = string;
})
}
});
new Vue({
el: '#app2',
data: {
simpleString: ''
},
created: function () {
self = this;
eventBus.$on('stringUpdated', function(string){
self.simpleString = string;
})
}
});
eventBus.$emit('stringUpdated', 'hello just a string');