我们先看看通过接口回来的数据.
{
"message":"success",
"status":200,
"data":[
{
"id":2,
"rule_list":"{"title":[".item-text>h3","text"],"link":[".item-tit>a","href"]}",
"range_list":".item-phototext",
"author":"中华游戏网",
"name":"中华游戏网",
"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是需要回显的内容,即原选定的分类.
需要保证select下拉的ID和v-model里边的id保持一致
<el-form-item label="所属元素:" prop="defaultType">
<el-select v-model="ruleForm.defaultType.id" placeholder="请选择对应分类" @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>

网友评论