<template>
  <a-switch :checked='replacechecked'
            :disabled="disabled"
            @change="change"></a-switch>
</template>
<script>
export default {
  name: 'SwitchValue',
  props: {
    value: {},
    checked: {},
    disabled: {
      type: Boolean,
      default: false
    },
    defaultvalue: {
      type: Object,
      default() {
        return {
          on: 1,
          off: 0
        }
      }
    }


  },
  computed: {
    replacechecked() {
      return this.value === this.defaultvalue.on ? true : false
    }
  },
  data() {
    return {
    }
  },
  mounted() { },
  methods: {
    change(checked) {
      this.$emit('change', checked ? this.defaultvalue.on : this.defaultvalue.off)
      this.$emit('input', checked ? this.defaultvalue.on : this.defaultvalue.off)
    },
  }
}
</script>
<style lang='less'>
</style>
