下拉框选择内容后,其余input框与该下拉框相关的内容实时回显,用@change=加方法
<el-row><el-col :span="12"><el-form-item label="选择站点" prop="resourcesId"><el-select v-model="form.resourcesId" @change="updateInput" placeholder="请选择要申请的站点"><el-option v-for="item in tableList" :key="item.id" :label="item.stationName" :value="item.id":disabled="item.status == 1"></el-option></el-select></el-form-item></el-col><el-col span="12"><el-form-item label="租金" prop="amount"><el-input v-model="form.amount" placeholder="请输入租金" /></el-form-item></el-col></el-row><el-row><el-col span="12"><el-form-item label="开始日期" prop="beginTime"><el-date-picker clearable v-model="form.beginTime" type="date" value-format="yyyy-MM-dd"placeholder="请选择租金开始日期"></el-date-picker></el-form-item></el-col>
change方法内容,tableList是数据数组
javascript">updateInput() {const selectedStationId = this.form.resourcesId;const selectedStation = this.tableList.find(item => item.id === selectedStationId);if (selectedStation && selectedStation.rent) {this.form.amount = selectedStation.amount;//租金this.form.beginTime = selectedStation.endTime;//时间// console.log(selectedStation.amount);} else {this.form.amount = '';}},