Vue.js 2.0 test

by Atinux

HTML

<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
  Title: <input type="text" v-model="title" />
  <p>Metas:</p>
  <pre>{{ $metaInfo }}</pre>
</div>

Babel + JSX

var metaInfo = {
  beforeCreate () {
	  this.$options.computed.$metaInfo = this.$options.metaInfo;
  },
  created () {
  	this.$watch('$metaInfo', (metas) => {
      console.log('Update', metas)
      // call this.$meta.refresh() here :D
    })
  }
}

new Vue({
	mixins: [metaInfo],
	el: '#app',
  data () {
  	return { title: 'I am a title' }
  },
  computed: {
  	description () { return 'Description: ' + this.title }
  },
  metaInfo () {
  	return {
    	title: this.title,
      meta: [
      	{ name: 'description', content: this.description }
      ]
    }
  }
});