<template> <div :class="type" class="function">{{ 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: { buttonClick (e) { this.$emit('press', this.type) }, }, } </script>