Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee 朱秋贵内科诊所 My腾云code

el-table新增记录,通过id获行记录的控件焦点


<el-table :data="formData.list" ref="tabRef" class="my-table" >

 <el-table-column label="编码" align="center" min-width="150" class="custom-form-item">
    <template #default="scope">
       <el-form-item :prop="'list[' + scope.$index + '].code'" >
    <el-input v-model="scope.row.code" placeholder="编码为必填"
     maxlength="32" minlength="8"
     :id="'input_'+scope.$index"   clearable></el-input>
      </el-form-item>
    </template>
</el-table-column>

 

</el-table>

 

 

 

 

 

 const { createApp, nextTick} = Vue

 //直接引用nextTick ,不需要this.$nextTick

 

//nextTick,获取更新后的 DOM

nextTick(() => {
        indexTemp=formData.value.list.length-1;
        ids="input_"+indexTemp.toString();
        console.log("ids "+ids);
        console.log("indexTemp "+indexTemp);
        console.log(ids+"...."+$('#'+ids));
        $('#'+ids).focus();
});

posted @ 2024-10-23 11:21  cn2024  阅读(9)  评论(0编辑  收藏  举报