Mr-Wiill/el-tree-select

点击选择后怎么关闭select?

Opened this issue · 5 comments

选择完后不能自动关闭select问题。导致不能用这个组件了~~

点击一下页面(非select区域),就会关闭select列表了

@KBeginner 这个要分单选和多选两种情况吧,单选情况下,选中即关闭,多选情况下,点击一下页面(非select区域),就会关闭select列表

@xiechunhao

template部分修改,给 <el-select 加上 ref="select" ,如下:

<template>
  <el-select :value="valueTitle"
             ref="select"

      后面代码省略..............

handleNodeClick(node)函数内 执行 this.$refs.select.blur(); ,如下:

// 切换选项
    handleNodeClick(node){
      this.valueTitle = node[this.props.label]
      this.valueId = node[this.props.value]
      this.$emit('getValue',this.valueId)
      this.defaultExpandedKey = []
      this.$refs.select.blur();
    }, 

@KBeginner 这个要分单选和多选两种情况吧,单选情况下,选中即关闭,多选情况下,点击一下页面(非select区域),就会关闭select列表

多选的情况没有啊

@xiechunhao

template部分修改,给 <el-select 加上 ref="select" ,如下:

<template>
  <el-select :value="valueTitle"
             ref="select"

      后面代码省略..............

handleNodeClick(node)函数内 执行 this.$refs.select.blur(); ,如下:

// 切换选项
    handleNodeClick(node){
      this.valueTitle = node[this.props.label]
      this.valueId = node[this.props.value]
      this.$emit('getValue',this.valueId)
      this.defaultExpandedKey = []
      this.$refs.select.blur();
    }, 

如果是单选,并且只希望选中叶子节点时自动关闭菜单,加上一个childre判断
if(node.children == null){
this.$refs.select.blur()
}