ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
点击input的选择按钮, ![](https://img.kancloud.cn/62/af/62af285b774e04cf1ca15c8120a6a301_709x62.png) 弹出一个表格,点击表格任何一行,获取到这行的id和名称,名称显示在input框 ![](https://img.kancloud.cn/43/24/4324d2b3a1a3ecfbc0a825f4a49fa30d_1082x484.png) 代码: ``` <el-form-item> <el-input v-model="form.typeIdVal" placeholder="请输入内容" class="input-with-select" readonly > <el-button slot="prepend" @click="showTypeIdAdd()">选择类型</el-button> </el-input> </el-form-item> ``` 点击选择类型按钮,弹出表格子组件 ``` //表格部分代码 <el-table ref="multipleTable" :data="typeForData" tooltip-effect="dark" style="width: 100%" :header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }" > <el-table-column prop="id" label="序号" width="100"> //通过作用域插槽,获取到这行的id和lanId <template slot-scope="scope"> <span class="ds" @click="getId(scope.row.lanID, scope.row.id)">{{ scope.row.id }}</span> </template> </el-table-column> <el-table-column prop="lanID" label="类型"> <template slot-scope="scope"> <span class="ds" @click="getId(scope.row.lanID, scope.row.id)">{{ scope.row.lanID }}</span> </template> </el-table-column> </el-table> //方法:数据传递到父组件中,父组件接收 <script> getId(lanVal, id) { this.$emit("getMtIdVal", lanVal, id); this.dialogVisibleBasicTypeAddition = false; }, </script> //样式:目的是让span为块元素 <style> .ds { display: block; width: 100%; } </style> ```