vue element-ui select框選中回顯

我們先看看通過接口回來的數(shù)據(jù).

{
    "message":"success",
    "status":200,
    "data":[
        {
            "id":2,
            "rule_list":"{"title":[".item-text>h3","text"],"link":[".item-tit>a","href"]}",
            "range_list":".item-phototext",
            "author":"中華游戲網(wǎng)",
            "name":"中華游戲網(wǎng)",
            "handle":"chinaGame",
            "url":"[https://game.china.com/news/jx/](https://game.china.com/news/jx/)",
            "rule_content":"{"title":["h1","text"],"link":["#chan_newsDetail","html"]}",
            "range_content":"",
            "encoding":0,
            "status":1,
            "full_url":"",
            "gather_types":1,
            "defaultType":{
                "id":1,
                "name":"新聞"
            }
        }
    ]
}

其中,defaultType是需要回顯的內(nèi)容,即原選定的分類.

需要保證select下拉的ID和v-model里邊的id保持一致

<el-form-item label="所屬元素:" prop="defaultType">
      <el-select v-model="ruleForm.defaultType.id" placeholder="請選擇對應(yīng)分類" @change="obtainValue">
      <el-option v-for="getType in ruleForm.defaultType" :key="getType.id" :label="getType.name" :value="getType.id"></el-option>
    </el-select>
    </el-form-item>
image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

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

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