vue-selectTree

vue-selectTree并且修改样式和el-select下拉框样式一致。

注意下拉多选,后台数据传参问题。

可拖拽分隔栏,

1.安装依赖

"@riophae/vue-treeselect": "0.4.0"

2.工程入口文件main.js全局配置

import Treeselect from '@riophae/vue-treeselect' // 导入vue-treeselect
import '@riophae/vue-treeselect/dist/vue-treeselect.css' // 导入样式
Vue.component('Treeselect', Treeselect); // 注册组件

3.标签

<Treeselect :disable-branch-nodes="true" :multiple="true" :options="deptNameOptions" :normalizer="normalizer" placeholder="出院科室" v-model="searchForm.outDeptCodes" :limit="1" :limitText="count => `+${count}`" noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果">
          <p style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;width: 90%;" slot="option-label" slot-scope="{node}" :title="node.label">
            <template> {{ node.label }}</template>
          </p>
        </Treeselect>

4.其他逻辑代码

  data() {
    return {
      // 住院科室下拉树
      deptNameOptions: [],
    }
  },
  methods: {
    normalizer: (node) => {
      if(node.childs && !node.childs.length) delete node.childs;
      return {
        id: node.id,
        label:node.name,
        children:node.childs
      }
    },
  },

5.样式

<style lang="scss" scoped>
::v-deep(.vue-treeselect){
  width:240px;
  height:28px;
  display:inline-flex;
  .vue-treeselect__control{
    height: 28px;
    .vue-treeselect__placeholder, .vue-treeselect__single-value{
      line-height: 28px;
    }
    .vue-treeselect__value-container{
      .vue-treeselect__multi-value{
        margin-bottom:0;
        display: flex;
        .vue-treeselect__multi-value-item-container{
          max-width: 80%;
          .vue-treeselect__multi-value-item{
            max-width: 100%;
            display: flex;
            align-items: center;
            .vue-treeselect__multi-value-label{
              white-space: nowrap;
              text-overflow: ellipsis;
              overflow: hidden;
              display: inline-block;
              // max-width: 80%;
            }
          }
        }
      }
    }
  }
}
</style>

6.效果

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值