Skip to content

Instantly share code, notes, and snippets.

@voronianski
Created June 18, 2016 13:07
Show Gist options
  • Save voronianski/265d5764682b911ae04f6aa923297d03 to your computer and use it in GitHub Desktop.
Save voronianski/265d5764682b911ae04f6aa923297d03 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
<div id="app"></div>
</body>
</html>
import Vue from '[email protected]';
import Vuex from 'vuex';
Vue.use(Vuex);
const store = new Vuex.Store({
state: {
count: 0,
name: 'Vue 2.0'
},
mutations: {
increment(state) {
state.count++;
}
}
})
const vm = new Vue({
el: '#app',
store,
vuex: {
getters: {
name: state => state.name,
count: state => state.count
}
},
methods: {
handleClick() {
store.dispatch('increment');
}
},
render(h) {
return (
h('div', {}, [
h('h2', {}, [`Hello ${this.name}!`]),
h('div', {}, [
h('h3', {}, [this.count]),
h('button', {
attrs: {id: 'cta'},
on: {click: this.handleClick}
}, 'Increment')
])
])
);
}
});
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"vue": "2.0.0-alpha.5",
"vuex": "0.6.3"
}
}
'use strict';
var _vue200Alpha = require('[email protected]');
var _vue200Alpha2 = _interopRequireDefault(_vue200Alpha);
var _vuex = require('vuex');
var _vuex2 = _interopRequireDefault(_vuex);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_vue200Alpha2.default.use(_vuex2.default);
var store = new _vuex2.default.Store({
state: {
count: 0,
name: 'Vue 2.0'
},
mutations: {
increment: function increment(state) {
state.count++;
}
}
});
var vm = new _vue200Alpha2.default({
el: '#app',
store: store,
vuex: {
getters: {
name: function name(state) {
return state.name;
},
count: function count(state) {
return state.count;
}
}
},
methods: {
handleClick: function handleClick() {
store.dispatch('increment');
}
},
render: function render(h) {
return h('div', {}, [h('h2', {}, ['Hello ' + this.name + '!']), h('div', {}, [h('h3', {}, [this.count]), h('button', {
attrs: { id: 'cta' },
on: { click: this.handleClick }
}, 'Increment')])]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment