Vue

by kabanoki

HTML

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script>
<div id="app">
  <toggle-button @change="onChangeEventHandler"></toggle-button>

  <toggle-button v-model="myDataVariable"></toggle-button>
  
  <toggle-button :value="false"
                 color="#82C7EB"
                 :sync="true"
                 :labels="true"></toggle-button>
  
  <toggle-button :value="true"
                 :labels="{checked: 'Foo', unchecked: 'Bar'}"></toggle-button>
 <toggle-button :value="false"
                 color="#82C7EB"
                 height="40"
                 width="84"
                 :sync="true"
                 :labels="true"></toggle-button>                
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>

CSS

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

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

Vue

Vue.use(window['vue-js-toggle-button'].default)
 new Vue({
   el: '#app',
   data: {
    myDataVariable: ''
   },
   methods: {
    onChangeEventHandler: function(){
      console.log('onChangeEventHandler');
    }
   }
 })