美文网首页
ElementUI-Cascader组件同时支持懒加载和选择任意

ElementUI-Cascader组件同时支持懒加载和选择任意

作者: 与你何干_1bc9 | 来源:发表于2020-12-11 18:14 被阅读0次

    正确的方法附上链接

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

    相关文章

      网友评论

          本文标题:ElementUI-Cascader组件同时支持懒加载和选择任意

          本文链接:https://www.haomeiwen.com/subject/ktxsgktx.html