鍍金池/ 問答/HTML/ element ui select 初始值設定

element ui select 初始值設定

代碼如下,表格中的el-select,看了網(wǎng)上說明一般都是在data中設置(比如risk_type設置為0),但我這表格中他的初始值不相同,這個該如何設置。試過將select綁定值設為scope.row.risk_type,但是 @change的選中值無法獲取

 <el-table-column
          prop="status" :formatter="showStatus"
          label="狀態(tài)">
  </el-table-column>
  <el-table-column
          prop="risk_type"
          label="單控操作">
          <template slot-scope="scope" >
            <el-select v-model="controlSetting.risk_type"
                       @change="orderEdit(scope.row.id)" v-if="scope.row.status==0" size="mini">
              <el-option label="默認" value="0"></el-option>
              <el-option label="贏了" value="1"></el-option>
              <el-option label="損虧" value="2"></el-option>
            </el-select>
            <span v-if="scope.row.status!=0">已完成</span>
          </template>
        </el-table-column>
   data() {
      return {
        proData:[],
        data:[],
        count:0,
        page:1,
        controlSetting:{
          risk_type: '',
          id: ''
        },
  orderEdit:function(id){
        var _this=this;
        _this.controlSetting.id=id;
        _this.axios.post(_this.global.httpUrl+"?r=order/update",_this.qs.stringify( _this.controlSetting))
          .then(function (response) {
            if(response.data.status=="SUCCESS"){
              _this.data=response.data.results;
              _this.$message.success('修改成功');
              _this.allSearch();
            }else{
              _this.loginStatus(response.data.status,response.data.error_message);
            }

          })
          .catch(function (error) {
            console.log(error);
          });
      }
回答
編輯回答
貓館

change方法里的參數(shù)是目前的選中值,不支持自定義,即你設置的scope.row.id不生效,請看:ElSelect文檔。

2017年10月5日 18:28