Vue.component("values-box", { props: ["values", "size", "maxlength", "name"], data: function () { let values = this.values; if (typeof (values) != "object") { values = []; } return { "vValues": values, "isUpdating": false, "isAdding": false, "index": 0, "value": "" } }, methods: { create: function () { this.isAdding = true; var that = this; setTimeout(function () { that.$refs.value.focus(); }, 200); }, update: function (index) { this.cancel() this.isUpdating = true; this.index = index; this.value = this.vValues[index]; var that = this; setTimeout(function () { that.$refs.value.focus(); }, 200); }, confirm: function () { if (this.isUpdating) { Vue.set(this.vValues, this.index, this.value); } else { this.vValues.push(this.value); } this.cancel() this.$emit("change", this.vValues) }, remove: function (index) { this.vValues.$remove(index) this.$emit("change", this.vValues) }, cancel: function () { this.isUpdating = false; this.isAdding = false; this.value = ""; } }, template: '
\
\
{{value}}\ \   \ \
\
\ \
\
\
\ \
\
\ \
\
\ 取消 \
\
\
\
\ \
\
' });