當下拉數據是個接口,且后臺表單和列表中給的參數是Id,但要顯示接口中的id對應的名稱
先在data中定義要顯示的名稱 productName
1.form下拉
<el-form-item label="產品名稱" prop="productId"><el-select v-model="queryParams.productId" clearable placeholder="請輸入產品名稱" style="width: 100%" ><el-optionv-for="item in productNameList":key="item.id":label="item.productName":value="item.id"/></el-select></el-form-item>
2.列表中
<el-table-column label="產品名稱" align="center" prop="productId" ><template slot-scope="scope"><span v-show="isDisable=true">{{getProductName(scope.row.productId)}}</span><span>{{productName}}</span></template></el-table-column>
3.轉化方法
getProductName(val){for (let i=0;i<this.productNameList.length;i++){val !=null || val !== void 0? this.productName = this.productNameList.find(item => item.id === val).productName : this.productName == null}}