Vue

by yusuke_ten

HTML

<div id="example">

  <my-component></my-component>
  <my-component></my-component>
  <my-component></my-component>
  <my-component></my-component>
  
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

.component {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

Vue

// 登録する
Vue.component('my-component', {

  template: '<div><button v-on:click="change_function">{{ button_text }}</button><div>',
  
  data: function () {
    return {
      button_text: 'お前を芸術品に仕立てや・・・'
    }
  },
  
  methods: {
  	change_function: function () {
      this.button_text = '仕立てあげてやんだよ'
    }
  }
  
})

// root インスタンスを作成する
new Vue({
  el: '#example'
})