<template>
  <div :class="type" class="function" @touchstart.capture="touchStart">{{ text }}</div>
</template>

<script>
export default {
  name: 'OptionButton',
  props: {
    type: {
      type: String,
      default: 'warn',
    },
    text: {
      type: String,
      default: '删除',
    },
  },
  mounted () {
    this.$parent && this.$parent.optionItem.push(this)
  },
  destroyed () {
    this.$parent && this.$parent.optionItem.splice(this.$parent.optionItem.indexOf(this), 1)
  },
  methods: {
    touchStart (ev) {
      this.$parent.reset()
    },
  },
}
</script>
