一、解决问题:当后台传过来的数据格式没有children的时候还加一个children:[],造成多渲染一个空选择框
1.解决方法:
<el-cascader
@change="addHandleChange"
:options="options"
change-on-select
:props="props"
v-model="selectedOptions1"
>
</el-cascader>
2.使用js方法去除空[],和空{}
实现效果
//获取菜单树
getTree(this.addForm.usId).then(response1=>{
console.log(this.addForm.usId)
this.options = response1.data
//过滤参数,去掉空值
toType(this.options)
filterNull(this.options)
function toType (obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
function filterNull (o) {
for (var key in o) {
if (o[key