VUE動(dòng)態(tài)生成Element-UI的select不回顯問(wèn)題

話(huà)嘮不話(huà)嘮,直接說(shuō)正題!

大概代碼如下,在一個(gè)可展開(kāi)的table里,點(diǎn)擊展開(kāi)按鈕,加載select組件。

<!-- 省略前面代碼 -->
    <!-- expandable table information -->
    <el-table-column type="expand">
      <template>
          <el-form :inline="true" :model="formInline"  size="mini" >
            <el-form-item label="查看方式">
              <el-select v-model="formInline.region" placeholder="select">
                <el-option label="區(qū)域一" value="shanghai"></el-option>
                <el-option label="區(qū)域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
      </template>
    </el-table-column>
<!-- 省略后面代碼 -->
<script>
export default {
  data() {
    return {
      formInline: {
        user: '',
        region: ''
      }
    }
  }
}
</script>

以上內(nèi)容均復(fù)制自element-ui官網(wǎng)

效果

當(dāng)table表格展開(kāi)后,加載一個(gè)下拉框,再點(diǎn)擊下拉框加載其他內(nèi)容。

但是這時(shí)會(huì)發(fā)現(xiàn),無(wú)論選中什么,都不會(huì)回顯。

在網(wǎng)上查了類(lèi)似都問(wèn)題,大多數(shù)都是因?yàn)楫惒郊虞d導(dǎo)致都,解決方法大概有兩類(lèi),如下:

1. this.$forceUpdate();
2. this.$set(targetObject,targetKey,targetValue);

兩種方式我都嘗試了,并不適合。

經(jīng)過(guò)各種嘗試,找到了適合自己都第三種方式,僅供大家參考:

  <!-- 省略前面代碼 -->
      <!-- expandable table information -->
      <el-table-column type="expand">
        <!-- 在template模板上添加屬性  slot-scope="scope" -->
        <template slot-scope="scope">
            <el-form :inline="true" :model="formInline"  size="mini" >
                <!-- 省略中間代碼 -->
            </el-form>
        </template>
      </el-table-column>
<!-- 省略后面代碼 -->
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容