Vue.js & Vuex Language Selector

Vue.js with Vuex. Inspired by https://jsfiddle.net/simon10/qh7r3oj5/

by ikbelkirasan

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/2.1.2/vuex.js"></script>
<div id="app">
  <h1>
    {{name}}
  </h1>
  
  <test></test>
</div>

Babel + JSX

let store = new Vuex.Store({
	state: {
  	name: 'Kira'
  },
  mutations: {
  	add(state, new_name) {
    	state.name = new_name
    }
  }
});


Vue.component('test', {
	template: '<span>{{name}}</span>',
  //store: store,
  computed: {
  	name() {
    	return this.$store.state.name;
    }
  },
  
  created() {
  	console.log('Test component:');
    console.log(this);
  }
});

const app = new Vue({
	el: '#app',
  store: store,
  computed: {
  	name() {
    	return this.$store.state.name;
    }
  },
  created() {
  	console.log(this);
  }
});