正确的方法附上链接
https://www.jianshu.com/p/209e690d0a00
我这个方法真是垃圾 下面记录我这失败的方法 这个方法不好
// template
<el-cascader ref="receivingUnitId" style="width:100%" @visible-change="dialog.form.unitList.visible('receivingUnitId')" @expand-change="dialog.form.unitList.expand('receivingUnitId')" v-model="dialog.form.data.receivingUnitId" filterable :options="dialog.form.unitList.data" :props="dialog.form.unitList.props"></el-cascader>
// js
get (node = {}, resolve) {
ajax.getProjectDepartmentOrganizeFindByParentUuid({
parentUuid: node.data && node.data.uuid || ''
}).then(({ data }) => {
data.map(item => {
item.children = undefined
})
if (resolve) {
if (data.length) {
resolve(data)
this.dialog.form.unitList.expand(type)
} else {
resolve(undefined)
}
} else {
data.map(item => item.children = [])
this.dialog.form.unitList.data = data
}
})
}
expand (type) {
if (!type) return false
this.dialog.form.unitList.current = type
this.$nextTick(() => {
let len = this.$refs[type].$children[1].$children.length
if (this.$refs[type].$children[1].menus.slice(-1)[0].length <= 0) {
this.$refs[type].$children[1].$children[len - 1].$el.style.display = 'none'
} else {
this.$refs[type].$children[1].$children[len - 1].$el.style.display = ''
}
})
},
主要是找到相应dom,判断nodes 隐藏框框
网友评论