Vue 2.0 Hello World
by ksoncan34
HTML
<script src="https://unpkg.com/vue"></script>
<div id="app">
<p>{{ message }}</p>
<input type="text" ref="text">
<button @click="okClicked($refs.text)">Click Me
</button>
</div>
JavaScript
class EventSync {
constructor() {
this._events = {};
}
trigger(event, ...args) {
if (this._events[event] && this._events[event].length > 0) {
for (let i = 0; i < this._events[event].length; i++) {
this._events[event][i].apply(this, args);
}
}
}
on(event, fn) {
if (!this._events[event]) {
this._events[event] = [];
}
this._events[event].push(fn);
}
off(event, fn) {
if (fn) {
this._events[event] = _.without(StorefrontFunctions._events[event], fn) as any;
} else {
StorefrontFunctions._events[event] = [];
}
}
}
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
},
mounted: {
},
methods: {
okClicked: function (text) {
this.message = text.value;
}
}
})