This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2020-08-04 07:15:41 -07:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div v-for="(synonym, i) in val" :key="i" class="input-group input-group-sm p-1">
|
2020-08-06 06:59:08 -07:00
|
|
|
<input type="text" class="form-control" v-model="val[i]" required ref="inp" maxlength="24">
|
2020-11-25 15:05:39 -08:00
|
|
|
<div v-if="i || !required" class="input-group-append">
|
2020-08-04 07:15:41 -07:00
|
|
|
<button type="button" class="btn btn-outline-danger btn-sm" @click="remove(i)">
|
|
|
|
<Icon v="times"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="p-1">
|
|
|
|
<button type="button" class="btn btn-outline-success btn-sm btn-block" @click="add">
|
|
|
|
<Icon v="plus"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: {required: true},
|
2020-11-25 15:05:39 -08:00
|
|
|
required: {type: Boolean}
|
2020-08-04 07:15:41 -07:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
val: this.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
val() {
|
|
|
|
this.$emit('input', this.val);
|
|
|
|
},
|
|
|
|
value() {
|
|
|
|
this.val = this.value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
add() {
|
|
|
|
this.val.push('');
|
|
|
|
this.$nextTick(_ => {
|
|
|
|
this.$refs.inp[this.$refs.inp.length - 1].focus()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
remove(i) {
|
|
|
|
this.val.splice(i, 1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|