ElementUI-Cascader组件同时支持懒加载和选择任意一级 不想显示空页的问题

正确的方法附上链接

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 隐藏框框

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容