问题:页面刷新后第一个input可以聚焦,第二个以后不能聚焦
解决方案:
<span v-if="visible" @dblclick="editContent" class="machine-info">{{variableInfo}}</span>
<el-input v-else size="mini" ref="textInput" v-model="variableInfo" @keyup.enter.native="confirmEdit"
@blur="confirmEdit"></el-input>
name: 'EditCell',
props: {
value: {}
},
watch: {
value () {
this.copyValue()
}
},
data () {
return {
item:{
textInput:''
},
visible: true,
variableInfo: '',
}
},
mounted () {
this.copyValue()
},
methods: {
copyValue () {
this.variableInfo = this.value
},
editContent () {
this.visible = false
this.$nextTick(()=>{
if(this.$refs.textInput){
this.$refs.textInput.focus()
}
})
},
confirmEdit () {
this.visible = true
this.$emit('input', this.variableInfo)
}
},
}
#