目 录CONTENT

文章目录

element Transfer 穿梭框 自定义

Jacky
2024-10-16 / 0 评论 / 0 点赞 / 86 阅读 / 3049 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2024-10-16,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

示例图

<template>
    <div class="dvSonOwner">
      <el-transfer
        class="custom-transfer"
        filterable
        :filter-method="filterMethod"
        filter-placeholder=""
        :titles="['Waiting List', 'Assign List']"
        v-model="Owner"
        :props="{
          key: 'desc',
          label: 'label',
        }"
        :format="{
          noChecked: 'Total:${total}',
          hasChecked: 'Total:${total}',
        }"
        :data="data"
        :render-content="renderContent"
      >
      </el-transfer>
    </div>
</template>
<script>
export default {
  name: "opUserList",
  data() {
    return {
      dialogVisible: false,
      Owner: [],
      data: [],
    };
  },
  methods: {
    filterMethod(query, item) {
      console.info(query);
      console.info(item);
      return item.desc.indexOf(query) > -1;
    },
    renderContent(h, option) {
      return h("span", [
        h("i", { class: "fas fa-user" }), // 自定义图标
        h("span", " "),
        h("span", option.label),
        h("span", " "),
        h("span", "(" + option.desc + ")"),
      ]);
    },
  },
  created() {
    this.data.push({
      desc: "zhangsan",
      label: `张三`,
    });
    this.data.push({
      desc: "lisi",
      label: `李四`,
    });
    this.data.push({
      desc: "wangwu",
      label: `王五`,
    });
  },
};
</script>
<style>
.dvSonOwner {
  display: flex;
  justify-content: center;
  align-items: center;
}

.custom-transfer .el-transfer-panel {
  width: 300px;
}
</style>

图标使用的是图标库 – Font Awesome 中文网 (p2hp.com)

0

评论区