我們先看看通過接口回來的數(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