vue实现自定义树形组件

欢迎点击关注-前端面试进阶指南:前端登顶之巅-最全面的前端知识点梳理总结

*分享一个使用比较久的🪜

效果展示:

在这里插入图片描述

近期的一个功能需求,实现一个树形结构:可点击,可拖拽,右侧数据可以拖拽到对应的节点内,可创建文件夹、可创建文件、编辑文件名、可删除等等;

渲染列表数据的时候,列表的子项还是列表。针对多层级的列表,我们采用tree的方式,从根节点一次创建绑定子节点的方式,可以递归式的调用本身,对我们的树形结构进行展示;并且支持多余的树形拓展;

代码区域

1、创建TreeList文件夹,其中创建:fonts文件夹、index.js文件、tools.js文件、Tree.js文件、VueTreeList.vue文件;
2、fonts文件夹主要用来存放icon图标的,这里就不展示了,依据项目在阿里矢量图标内新增,然后在VueTreeList.vue内进行替换

使用

源代码地址

 <vue-tree-list
    ref="VueTreeList"
    :model="treeData" // 初识数据源,treeData: new Tree([]),
    :activeId="activeId" // 选中的id及背景色
    default-leaf-node-name="新建文件" // 默认创建文件名称
    default-tree-node-name="新建目录" // 默认创建文件夹名称
    :default-expanded="isExpanded" // 默认是否展开文件夹
    @click="handleOnClick" // 点击当前节点
    @moveGraph="moveGraph" // 右侧数据拖拽至当前节点触发,可删除不使用
    @add-node="handleOnAddNode" // 点击创建节点
    @end-edit="handleOnChangeNameEnd" // 点击编辑当前节点的名称
    @delete-node="deleteNode" // 点击删除当前节点
    @drop="handleDrop" // 拖拽上下节点我已注释掉,依据需求自身放开
    @drop-before="hadnleDropBefore" // 开始拖拽之前的触发函数
    @drop-after="handleDropAfter" // 结束拖拽完之后的触发函数
    loadDataApi="/api/tree-dir" // 点击左侧icon,触发远程加载填充子数据Api接口
>
</vue-tree-list>
1.1 创建index.js文件,也是往外暴露的入口文件;(文章并未按照思路排序)
/**
 * Created by ayou on 17/7/21.
 */

import VueTreeList from './VueTreeList'
import { Tree, TreeNode } from './Tree'

VueTreeList.install = Vue => {
  Vue.component(VueTreeList.name, VueTreeList)
}

export default VueTreeList

export { Tree, TreeNode, VueTreeList }

1.2 创建tools.js文件;
/**
 * Created by ayou on 18/2/6.
 */

var handlerCache

export const addHandler = function(element, type, handler) {
  handlerCache = handler
  if (element.addEventListener) {
    element.addEventListener(type, handler, false)
  } else if (element.attachEvent) {
    element.attachEvent('on' + type, handler)
  } else {
    element['on' + type] = handler
  }
}

export const removeHandler = function(element, type) {
  if (element.removeEventListener) {
    element.removeEventListener(type, handlerCache, false)
  } else if (element.detachEvent) {
    element.detachEvent('on' + type, handlerCache)
  } else {
    element['on' + type] = null
  }
}

// depth first search
export const traverseTree = (root) => {
  const { children, parent, ...newRoot } = root;

  if (children && children.length > 0) {
    newRoot.children = children.map(traverseTree);
  }

  return newRoot;
};

1.2 创建Tree.js文件;
import { traverseTree } from './tools'

export class TreeNode {
  constructor(data) {
    const { id, isLeaf, editNode } = data
    this.id = typeof id !== 'undefined' ? id : Math.floor(new Date().valueOf() * (Math.random() + 1))
    this.parent = null
    this.children = null
    this.isLeaf = !!isLeaf
    this.editNode = editNode || false
    for (const key in data) {
      if (key !== 'id' && key !== 'children' && key !== 'isLeaf') {
        this[key] = data[key]
      }
    }
  }


  changeName(name) {
    this.name = name
  }

  changeNodeId(id) {
    this.id = id
  }

  addChildren(children) {
    if (!this.children) {
      this.children = []
    }
    if (Array.isArray(children)) {
      children.forEach(child => {
        child.parent = this
        child.pid = this.id
      })
      this.children.push(...children)
    } else {
      const child = children
      child.parent = this
      child.pid = this.id
      this.children.push(child)
    }
  }

  // remove self
  remove() {
    const parent = this.parent
    const index = parent.children.findIndex(child => child === this)
    parent.children.splice(index, 1)
  }

  // remove child
  _removeChild(child, bool) {
    const index = this.children.findIndex(c => bool ? c.id === child.id : c === child)
    if (index !== -1) {
      this.children.splice(index, 1)
    }
  }

  isTargetChild(target) {
    let parent = target.parent
    while (parent) {
      if (parent === this) {
        return true
      }
      parent = parent.parent
    }
    return false
  }

  moveInto(target) {
    if (this.name === 'root' || this === target) {
      return
    }
    if (this.isTargetChild(target)) {
      return
    }
    if (target.isLeaf) {
      return
    }
    this.parent.removeChild(this)
    this.parent = target
    this.pid = target.id
    if (!target.children) {
      target.children = []
    }
    target.children.unshift(this)
  }

  findChildIndex(child) {
    return this.children.findIndex(c => c === child)
  }

  _canInsert(target) {
    if (this.name === 'root' || this === target) {
      return false
    }
    if (this.isTargetChild(target)) {
      return false
    }
    this.parent.removeChild(this)
    this.parent = target.parent
    this.pid = target.parent.id
    return true
  }

  insertBefore(target) {
    if (!this._canInsert(target)) return
    const pos = target.parent.findChildIndex(target)
    target.parent.children.splice(pos, 0, this)
  }

  insertAfter(target) {
    if (!this._canInsert(target)) return
    const pos = target.parent.findChildIndex(target)
    target.parent.children.splice(pos + 1, 0, this)
  }

  toString() {
    return JSON.stringify(traverseTree(this))
  }
}

export class Tree {
  constructor(data) {
    this.root = new TreeNode({ name: 'root', isLeaf: false, id: 0 })
    this.initNode(this.root, data)
    return this.root
  }

  initNode(node, data) {
    data.forEach(_data => {
      const child = new TreeNode(_data)
      if (_data.children && _data.children.length > 0) {
        this.initNode(child, _data.children)
      }
      node.addChildren(child)
    })
  }
}

1.3 创建VueTreeList.vue文件;

说明:支持点击创建远程数据,loadDataAjax方法,需要自己研究功能小编已实现;现有代码基本功能已经完善,需要依赖自己的项目进行变更和更改;treeNode可以直接访问和修改数据源的,需要读者自己发掘;

<template>
  <div :class="['vtl', isMobile && 'isMobile']">
    <div
      v-if="model.name !== 'root'"
      :id="model.id"
      class="vtl-node"
      :class="{ 'vtl-leaf-node': model.isLeaf, 'vtl-tree-node': !model.isLeaf }"
    >
      <div class="vtl-border vtl-up" :class="{ 'vtl-active': isDragEnterUp }" />
      <div
        :class="['vtl-node-main', { 'vtl-active': isDragEnterNode }]"
        :style="{ fontSize: '10px' }"
        @drop="drop"
        @mouseover="mouseOver"
        @mouseout="mouseOut"
        @click.stop="handleCurClick"
        @dragover="dragOver"
        @dragenter="dragEnter"
        @dragleave="dragLeave"
      >

      <span
          v-if="!model.children"
          class="vtl-caret vtl-is-small"
        >
          <i
            class="vtl-icon"
            style="cursor: pointer; width: 11px;"
          ></i>
        </span>

        <span
          v-if="model.children"
          class="vtl-caret vtl-is-small"
        >
          <i
            class="vtl-icon"
            :class="caretClass"
            style="cursor: pointer"
            @click.prevent.stop="toggle"
          ></i>
          <i
            v-if="isRemoteLoading"
            class="Custom_demo-spin-icon-load ivu-icon ivu-icon-ios-loading"
            style="font-size: 16px; margin-right: 3px; margin-top: -2px"
          ></i>
        </span>

        <span v-if="model.isLeaf">
          <slot
            name="leafNodeIcon"
            :expanded="expanded"
            :model="model"
            :root="rootNode"
          >
            <i
              style="cursor: pointer"
              class="vtl-icon vtl-menu-icon vtl-icon-file"
            ></i>
          </slot>
        </span>
        <span v-else>
          <slot
            name="treeNodeIcon"
            :expanded="expanded"
            :model="model"
            :root="rootNode"
          >
            <img
              class="custom_img"
              style="width:15px;margin-right: 3px"
              src="../../../static/img/folder.png"
              alt=""
            />
          </slot>
        </span>

        <div
          v-if="!editable"
          :class="[
            'vtl-node-content',
            isShowClickBackg,
            { custom_class_hiddle: isHover, custom_class_click: model.isLeaf }
          ]"
          :style="{
            color: model.matched ? '#D9262C' : null,
            cursor: 'pointer'
          }"
        >
          <slot
            name="leafNameDisplay"
            :expanded="expanded"
            :model="model"
            :root="rootNode"
          >
            {{ model.name }}
          </slot>
        </div>
        <input
          v-if="editable || handleInitEditable(model)"
          class="vtl-input"
          type="text"
          ref="nodeInput"
          :value="model.name"
          @input="updateName"
          @blur="setUnEditable"
          @keyup.enter="setUnEditable"
        />
        <div class="vtl-operation" v-show="isHover">
          <!-- 新增设备 -->
          <span
            title="新增设备"
            v-btn-key="rolespermiss.addDevice"
            @click.stop.prevent="createChild"
            v-if="
              (!model.isDevice || model.isDir === false) &&
                $route.path != '/autoMonitorBoard'
            "
          >
            <slot
              name="addLeafNodeIcon"
              :expanded="expanded"
              :model="model"
              :root="rootNode"
            >
              <i class="vtl-icon vtl-icon-plus"></i>
            </slot>
          </span>
          <!-- 编辑名称 -->
          <span
            title="编辑名称"
            v-btn-key="rolespermiss.editFolder"
            @click.stop.prevent="setEditable(true)"
            v-if="
              !model.editNodeDisabled &&
                !model.isDevice &&
                $route.path != '/autoMonitorBoard'
            "
          >
            <slot
              name="editNodeIcon"
              :expanded="expanded"
              :model="model"
              :root="rootNode"
            >
              <i class="vtl-icon vtl-icon-edit"></i>
            </slot>
          </span>
          <!-- 删除节点 -->
          <span
            title="删除节点"
            @click.stop.prevent="delNode"
            style="line-height: 14px;"
            v-if="$route.path != '/autoMonitorBoard'"
            v-btn-key="rolespermiss.deleteFolder"
          >
            <slot
              name="delNodeIcon"
              :expanded="expanded"
              :model="model"
              :root="rootNode"
            >
              <i class="vtl-icon vtl-icon-trash"></i>
            </slot>
          </span>
          <!-- 创建子目录 -->
          <span
            :title="defaultAddTreeNodeTitle"
            @click.stop.prevent="addChild(false)"
            v-btn-key="rolespermiss.createFolder"
            v-if="
              !model.addTreeNodeDisabled &&
                !model.isLeaf &&
                !model.isDevice &&
                $route.path != '/autoMonitorBoard'
            "
          >
            <slot
              name="addTreeNodeIcon"
              :expanded="expanded"
              :model="model"
              :root="rootNode"
            >
              <i class="vtl-icon vtl-icon-folder-plus-e"></i>
            </slot>
          </span>
          <!-- 详情按钮 -->
          <span
            title="设备详情"
            style="margin-top: -1px"
            @click.stop="handleViewDetail"
            v-btn-key="rolespermiss.folderDetail"
            v-if="!model.addTreeNodeDisabled && model.isLeaf && !model.isDevice"
          >
            <Icon style="color: #d9262c" type="ios-paper-outline" />
          </span>
        </div>
      </div>
      <div
        v-if="
          model.children &&
            model.children.length > 0 &&
            (expanded || model.expanded)
        "
        class="vtl-border vtl-bottom"
        :class="{ 'vtl-active': isDragEnterBottom }"
      ></div>
    </div>

    <div
      :class="{ 'vtl-tree-margin': model.name !== 'root' }"
      v-if="isFolder && (model.name === 'root' || expanded || model.expanded)"
    >
      <item
        :model="model"
        :title="model.name"
        v-for="model in model.children"
        :key="model.id"
        :activeId="activeId"
        :loadDataApi="loadDataApi"
        :rolespermiss="rolespermiss"
        :requestHeader="requestHeader"
        :default-tree-node-name="defaultTreeNodeName"
        :default-leaf-node-name="defaultLeafNodeName"
        :default-expanded="defaultExpanded"
      >
        <template v-slot:leafNameDisplay="slotProps">
          <slot name="leafNameDisplay" v-bind="slotProps" />
        </template>
        <template v-slot:addTreeNodeIcon="slotProps">
          <slot name="addTreeNodeIcon" v-bind="slotProps" />
        </template>
        <template v-slot:addLeafNodeIcon="slotProps">
          <slot name="addLeafNodeIcon" v-bind="slotProps" />
        </template>
        <template v-slot:editNodeIcon="slotProps">
          <slot name="editNodeIcon" v-bind="slotProps" />
        </template>
        <template v-slot:delNodeIcon="slotProps">
          <slot name="delNodeIcon" v-bind="slotProps" />
        </template>
        <template v-slot:leafNodeIcon="slotProps">
          <slot name="leafNodeIcon" v-bind="slotProps" />
        </template>
        <template v-slot:treeNodeIcon="slotProps">
          <slot name="treeNodeIcon" v-bind="slotProps" />
        </template>
      </item>
    </div>
  </div>
</template>

<script>
import { request } from "@/axios/index";
import { TreeNode } from "./Tree.js";
import { removeHandler } from "./tools.js";
import { isShowMobile } from "@/storage/storeutil";

let compInOperation = null;

export default {
  name: "vue-tree-list",

  props: {
    model: {
      type: Object
    },
    activeId: Number,
    rolespermiss: Object,
    loadDataApi: String,
    requestHeader: Object,
    defaultLeafNodeName: {
      type: String,
      default: "新建"
    },
    defaultTreeNodeName: {
      type: String,
      default: "新建"
    },
    defaultAddTreeNodeTitle: {
      type: String,
      default: "新建"
    },
    defaultExpanded: {
      type: Boolean,
      default: true
    }
  },

  data() {
    return {
      isHover: false,
      editable: false,
      isDragEnterUp: false,
      isDragEnterBottom: false,
      isDragEnterNode: false,
      isRemoteLoading: false,
      expanded: this.defaultExpanded,
      clickEditIcon: false
    };
  },

  computed: {
    rootNode() {
      var node = this.$parent;
      while (node._props.model.name !== "root") {
        node = node.$parent;
      }
      return node;
    },

    caretClass() {
      return this.model.expanded
        ? "vtl-icon-caret-down"
        : this.expanded
        ? "vtl-icon-caret-down"
        : "vtl-icon-caret-right";
    },

    isFolder() {
      return this.model.children && this.model.children.length;
    },

    isShowClickBackg() {
      const {
        model: { id }
      } = this;
      return { activeItem: id === this.activeId };
    },

    isMobile() {
      return isShowMobile();
    }

    // treeNodeClass() {
    //   const {
    //     model: { dragDisabled, disabled },
    //   } = this;
    //   return {
    //     "vtl-drag-disabled": dragDisabled,
    //     "vtl-disabled": disabled,
    //   };
    // },
  },

  methods: {
    updateName(e) {
      var oldName = this.model.name;
      this.model.changeName(e.target.value);
      this.rootNode.$emit("change-name", {
        id: this.model.id,
        oldName: oldName,
        newName: e.target.value,
        node: this.model
      });
    },

    // 点击左侧箭头异步加载子节点数据
    toggle() {
      if (this.model.expanded) {
        this.expanded = false;
      } else {
        this.expanded = !this.expanded;
      }
      this.model.expanded = false;
    },

    // 删除节点
    delNode() {
      this.rootNode.$emit("delete-node", this.model);
    },

    setEditable(bool) {
      this.clickEditIcon = bool || false;
      this.editable = true;
      this.$nextTick(() => {
        const $input = this.$refs.nodeInput;
        $input.focus();
        this.handleCurClick();
      });
    },

    setUnEditable(e) {
      if (this.editable === false) return;
      this.editable = false;
      this.model.editNode = false;
      var oldName = this.model.name;
      this.model.changeName(e.target.value);
      this.rootNode.$emit(
        "change-name",
        {
          id: this.model.id,
          oldName: oldName,
          newName: e.target.value,
          eventType: "blur"
        },
        this.model
      );
      this.rootNode.$emit(
        "end-edit",
        {
          id: this.model.id,
          oldName: oldName,
          newName: e.target.value
        },
        this.model,
        this.clickEditIcon
      );
      this.clickEditIcon = false;
    },

    // 新建目录
    handleInitEditable(row) {
      if (row.editNode) {
        this.setEditable();
      }
    },

    // 异步请求数据
    async loadDataAjax(Refresh) {
      if (Refresh) {
        this.model.isLeaf = true;
      }
      const { method, params, httpApi } = this.requestHeader || {};
      const httpUrl = this.model.isLeaf ? httpApi : this.loadDataApi;
      const requestParams = this.model.isLeaf
        ? { treeDirId: this.model.id, ...(params || {}) }
        : { id: this.model.id, ...(params || {}) };
      try {
        this.isRemoteLoading = true;
        const { code, data, message } = await request(
          method || "GET",
          httpUrl,
          requestParams
        );

        if (code !== 0) {
          return (
            (this.expanded = false),
            (this.isRemoteLoading = false),
            this.$Message.error("失败," + message || "请求失败")
          );
        }

        const dataSource = this.model.isLeaf ? data.deviceList : data.data;
        if (!dataSource) {
          return (this.expanded = false), (this.isRemoteLoading = false);
        }

        if (Array.isArray(dataSource) && dataSource.length) {
          dataSource.forEach(item => {
            const node = new TreeNode(item);
            if (Refresh && this.expanded) {
              this.model._removeChild(node, true);
            }
            this.model.addChildren(node, true);
          });
          this.expanded = true;
        }

        this.isRemoteLoading = false;
      } catch (err) {
        this.expanded = false;
        this.isRemoteLoading = false;
        throw new Error(err);
      }
    },

    mouseOver() {
      if (this.model.disabled) return;
      this.isHover = true;
    },

    mouseOut() {
      this.isHover = false;
    },

    // 点击当前节点
    handleCurClick() {
      this.rootNode.$emit(
        "click",
        {
          toggle: this.toggle,
          ...this.model
        },
        this.editable
      );
      if (this.$route.path=='/autoMonitorBoard') {
        this.toggle()
      }
    },

    // 查看详情
    handleViewDetail() {
      this.rootNode.$emit("viewDetail", {
        ...this.model
      });
    },

    // 新增子节点
    async addChild(isLeaf) {
      if (!this.expanded) {
        await this.loadDataAjax();
        this.handleAddChildren(isLeaf);
      } else {
        this.handleAddChildren(isLeaf);
      }
    },

    handleAddChildren(isLeaf) {
      const name = isLeaf ? this.defaultLeafNodeName : this.defaultTreeNodeName;
      this.expanded = true;
      var node = new TreeNode({ name, isLeaf, isDir: false });
      this.model.addChildren(node, true);
      this.rootNode.$emit("add-node", node);
    },

    createChild() {
      this.rootNode.$emit("create-child", {
        ...this.model,
        loadDataAjax: this.loadDataAjax
      });
    },

    // dragStart(e) {
    //   if (!(this.model.dragDisabled || this.model.disabled)) {
    //     compInOperation = this;
    //     e.dataTransfer.setData("data", "data");
    //     e.dataTransfer.effectAllowed = "move";
    //     return true;
    //   }
    //   return false;
    // },

    // dragEnd() {
    //   compInOperation = null;
    // },

    dragOver(e) {
      e.preventDefault();
      return true;
    },

    dragEnter(ev) {
      this.isDragEnterNode = true;
    },

    dragLeave() {
      this.isDragEnterNode = false;
    },

    drop(ev) {
      if (ev.dataTransfer && ev.dataTransfer.getData("data")) {
        const data = JSON.parse(ev.dataTransfer.getData("data"));
        this.isDragEnterNode = false;
        this.$Modal.confirm({
          title: "提示",
          content: `是否确定要移入【${this.model.title}】目录中?`,
          closable: true,
          maskClosable: true,
          onOk: () => {
            this.axios
              .request("POST", "/api/move", {
                id: data.id,
                treeDirId: this.model.id
              })
              .then(response => {
                if (+response.code === 0) {
                  this.$Message.success("移动成功!");
                  this.rootNode.$emit("moveGraph");
                } else {
                  // 提示错误
                  this.$Notice.error({
                    title: "查询失败",
                    desc: response.message || "请求失败",
                    duration: 5
                  });
                }
              });
          }
        });
        return;
      }
      if (!compInOperation) return;
      const oldParent = compInOperation.model.parent;
      compInOperation.model.moveInto(this.model);
      this.isDragEnterNode = false;
      this.rootNode.$emit("drop", {
        target: this.model,
        node: compInOperation.model,
        src: oldParent
      });
    }

    //   dragEnterUp() {
    //     if (!compInOperation) return;
    //     this.isDragEnterUp = true;
    //   },

    //   dragOverUp(e) {
    //     e.preventDefault();
    //     return true;
    //   },

    //   dragLeaveUp() {
    //     if (!compInOperation) return;
    //     this.isDragEnterUp = false;
    //   },

    //   dropBefore() {
    //     if (!compInOperation) return;
    //     const oldParent = compInOperation.model.parent;
    //     compInOperation.model.insertBefore(this.model);
    //     this.isDragEnterUp = false;
    //     this.rootNode.$emit("drop-before", {
    //       target: this.model,
    //       node: compInOperation.model,
    //       src: oldParent,
    //     });
    //   },

    //   dragEnterBottom() {
    //     if (!compInOperation) return;
    //     this.isDragEnterBottom = true;
    //   },

    //   dragOverBottom(e) {
    //     e.preventDefault();
    //     return true;
    //   },

    //   dragLeaveBottom() {
    //     if (!compInOperation) return;
    //     this.isDragEnterBottom = false;
    //   },

    //   dropAfter() {
    //     if (!compInOperation) return;
    //     const oldParent = compInOperation.model.parent;
    //     compInOperation.model.insertAfter(this.model);
    //     this.isDragEnterBottom = false;
    //     this.rootNode.$emit("drop-after", {
    //       target: this.model,
    //       node: compInOperation.model,
    //       src: oldParent,
    //     });
    //   },
  },

  beforeCreate() {
    this.$options.components.item = require("./VueTreeList").default;
  },

  beforeDestroy() {
    removeHandler(window, "keyup");
  }
};
</script>

<style lang="less">
@font-face {
  font-family: "icomoon";
  src: url("fonts/icomoon.eot?ui1hbx");
  src: url("fonts/icomoon.eot?ui1hbx#iefix") format("embedded-opentype"),
    url("fonts/icomoon.ttf?ui1hbx") format("truetype"),
    url("fonts/icomoon.woff?ui1hbx") format("woff"),
    url("fonts/icomoon.svg?ui1hbx#icomoon") format("svg");
  font-weight: normal;
  font-style: normal;
}

.vtl-icon {
  font-family: "icomoon" !important;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  &.vtl-menu-icon {
    margin-right: 4px;
    &:hover {
      color: inherit;
    }
  }
  &:hover {
    color: #d9262c;
  }
}

.vtl-icon-file:before {
  content: "\e906";
}
.vtl-icon-folder:before {
  content: "\e907";
}
.vtl-icon-caret-down:before {
  font-size: 16px;
  content: "\e901";
}
.vtl-icon-caret-right:before {
  font-size: 16px;
  content: "\e900";
}
.vtl-icon-edit:before {
  content: "\e902";
  font-size: 18px;
}
.vtl-icon-folder-plus-e:before {
  content: "\e903";
}
.vtl-icon-plus:before {
  content: "\e904";
  font-size: 16px;
}
.vtl-icon-trash:before {
  content: "\e905";
}

.vtl {
  cursor: default;
  margin-left: -3px;
}
.vtl-border {
  height: 5px;
  &.vtl-up {
    margin-top: -5px;
    background-color: transparent;
  }
  &.vtl-bottom {
    background-color: transparent;
  }
  &.vtl-active {
    border-bottom: 2px dashed pink;
  }
}

.vtl-node-main {
  display: flex;
  align-items: center;
  margin: 2.5px auto 2.5px -1px;
  .vtl-input {
    border: none;
    min-width: 200px;
    border-bottom: 1px solid blue;
  }
  &:hover {
    background-color: #f0f0f0;
  }
  &.vtl-active {
    outline: 1.5px dashed #d9262c;
  }

  .vtl-operation {
    display: flex;
    margin-left: 1rem;
    height: 18px;
    letter-spacing: 1px;
    span {
      margin-right: 10px;
    }
    .vtl-icon {
      color: #d9262c;
      vertical-align: sub;
    }
  }
}

.vtl-node-content {
  white-space: nowrap;
  padding: 1px 0px;
}

.activeItem {
  background: #ccc;
}
.custom_class_click {
  cursor: pointer;
}

.custom_class_hiddle {
  overflow: hidden;
  text-overflow: ellipsis;
}

.vtl-item {
  cursor: pointer;
}
.vtl-tree-margin {
  margin-left: 2em;
}

.Custom_demo-spin-icon-load {
  font-size: 18px;
  color: #d9262c;
  animation: ani-demo-spin 1s linear infinite;
}
@keyframes ani-demo-spin {
  from {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.demo-spin-col {
  height: 100px;
  position: relative;
  border: 1px solid #eee;
}

.vtl-caret {
  display: flex;
  .vtl-icon {
    width: 28px;
    text-align: right;
  }
}

.isMobile {
  .vtl {
    margin-left: 3px;
  }
  .vtl-node-content {
    white-space: nowrap;
    padding: 1px 0px;
    font-size: 2.6em;
  }
  .custom_img {
    width: 2.5em !important;
  }
  .vtl-icon-caret-down:before,
  .vtl-icon-caret-right:before,
  .vtl-icon-plus:before,
  .vtl-icon-edit:before,
  .vtl-icon-trash:before,
  .vtl-icon-folder-plus-e:before {
    font-size: 30px;
  }
  .vtl-node-main .vtl-operation {
    height: auto;
  }
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/93675.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

idea如何设置高亮显示选中的变量颜色

打开设置 设置颜色&#xff0c;挑你自己喜欢的&#xff0c;就好了 然后在你的编辑器页面里&#xff0c; 随便选中某个变量&#xff0c; 其他位置使用该变量的地方就会高亮显示

「Linux」使用VS Code远程连接Linux

一、VS Code简介 1.VS Code是什么&#xff1f; Visual Studio Code&#xff08;简称“VS Code”&#xff09;是微软公司的一个运行可以于 Mac OS、Windows 和 Linux之上的源代码编辑器。简单地说VS Code是一个编辑器&#xff0c;用来写代码。是一个基于插件的软件。 2.使用VSCo…

【多线程】Thread类的用法

文章目录 1. Thread类的创建1.1 自己创建类继承Thread类1.2 实现Runnable接口1.3 使用匿名内部类创建Thread子类对象1.4 使用匿名内部类创建Runnable子类对象1.5 使用lambda创建 2. Thread常见的构造方法2.1 Thread()2.2 Thread(Runnable target)2.3 Thread(String name)2.4 Th…

el-table 单击某一行,该行的前面的多选框显示已勾选

目 录 官网&#xff1a; 1. 单页面 2. table是组件 案例&#xff1a; 官网&#xff1a; 1. 单页面 通过单击获取当前行的数据&#xff0c;然后传给选中显示勾选的方法。 <template><el-tableref"multipleTable":data"tableData"tooltip-eff…

横扫“盲区”、“看透”缺陷,维视智造推出短波红外相机

在可见光领域&#xff0c;工业相机的视觉应用已经十分成熟&#xff0c;但在日常的客户咨询中&#xff0c;我们也经常接到一些“超纲需求”——客户想要检测“白底上的白色缺陷”、“不透明包装内的透明物体有无”等&#xff0c;均属于可见光无法实现的检测&#xff0c;而市面上…

C++ : implicit instantiation of undefined template ‘std::vector<_******>‘

编译报错 implicit instantiation of undefined template ‘std::vector<_struFontMap>’ 需要 #include add vector class

求解整数规划问题的割平面法和分支定界法

文章目录 整数规划割平面法分支定界法代码实现 整数规划 整数规划问题是优化变量必须取整数值的线性或非线性规划问题&#xff0c;不过&#xff0c;在大多数情况下&#xff0c;整数规划问题指的是整数线性规划问题。 其数学模型为 m i n f ( x ) c T x s.t A x b x ≥ 0 x…

Ansible学习笔记(二)

3.ansible的使用示例&#xff08;playbook&#xff09; 1.创建mysql 账户和mysql 组的 playbook ---#create mysql user and group - hosts: allremote_user: roottasks:- name: create groupgroup: namemysql systemyes gid306- name: create useruser: namemysql systemyes…

爬虫(bilibili热门课程记录)

什么是爬虫&#xff1f;程序蜘蛛&#xff0c;沿着互联网获取相关信息&#xff0c;收集目标信息。 一、python环境安装 1、先从Download Python | Python.org中下载最新版本的python解释器 2、再从Download PyCharm: Python IDE for Professional Developers by JetBrains中下…

【解决】idea启动spring MVC报错:一个或多个listeners启动失败Listener ClassNotFoundException

idea配置教程。tomcat调试报错Artifact :war exploded: Error during artifact deployment。 修改代码后&#xff0c;启动不生效&#xff0c;仍是旧代码。 根本原因是&#xff1a; Modules output path和Artifacts output directory不匹配 Modules output path一定要等于Ar…

Linux和其他类Unix系统的GNU coreutils 知多少

GNU coreutils是GNU项目的一部分&#xff0c;它是一组基本的命令行工具集&#xff0c;用于操作和管理Linux和其他类Unix系统中的文件和数据流。这些工具被广泛用于终端和脚本中&#xff0c;提供了许多常用的功能和实用程序。Linux和其他类Unix系统的GNU coreutils 知多少&#…

【JavaEE】Spring全家桶实现AOP-统一处理

【JavaEE】AOP&#xff08;2&#xff09; 文章目录 【JavaEE】AOP&#xff08;2&#xff09;1. 统一登录校验处理1.1 自定义拦截器1.2 将自定义拦截器加入到系统配置1.3 测试1.4 对于静态资源的处理1.5 小练习&#xff1a;统一登录拦截处理1.6 拦截器原理1.6.1 执行流程1.6.2 源…

习题练习 C语言(暑期第二弹)

编程能力小提升&#xff01; 前言一、表达式判断二、Assii码的理解应用三、循环跳出判断四、数字在升序数组中出现的次数五、整数转换六、循环语句的应用七、函数调用八、两个数组的交集九、C语言基础十、图片整理十一、数组的引用十二、数组的引用十三、字符个数统计十四、多数…

ssm校园快递一站式服务系统源码和论文

ssm校园快递一站式服务系统源码和论文076 开发工具&#xff1a;idea 数据库mysql5.7 数据库链接工具&#xff1a;navcat,小海豚等 技术&#xff1a;ssm 选题的目的和意义&#xff1a; 目的&#xff1a; 校园快递一站式服务系统的研究目的有两个&#xff0c;一个为校园及…

【案例】登录注册

<template><div class"loginhome"><Header :butShow"butShow"></Header><div class"formdiv"><div style"text-align:center;padding:10px;"><h3>你好登录账号{{ stauts 3? 注册:登录 }}…

轻松正确使用代理IP

Hey&#xff0c;亲爱的程序员小伙伴们&#xff01;在进行爬虫时&#xff0c;你是否曾使用过别人的代理IP&#xff1f;是否因此慌乱&#xff0c;担心涉及违法问题&#xff1f;不要惊慌&#xff01;今天我将和你一起揭开法律迷雾&#xff0c;为你的爬虫之路保驾护航。快跟上我的节…

无涯教程-机器学习 - 数据加载

假设如果要启动ML项目&#xff0c;那么您需要做的第一件事也是最重要的事情是什么?这是无涯教程启动任何ML项目都需要加载的数据。关于数据&#xff0c;对于ML项目&#xff0c;最常见的数据格式是CSV(逗号分隔值)。 基本上&#xff0c;CSV是一种简单的文件格式&#xff0c;用…

【Python】requests实现cookie 登陆

Python 系列 文章目录 Python 系列前言一、requests是什么&#xff1f;二、使用步骤1.引入库 总结 前言 session 登录获取接口数据的&#xff0c;操作不需要header 等数据&#xff0c;print(my_session.headers)&#xff0c;如果有需要可以自己重新去设置&#xff0c;包括cook…

无涯教程-PHP - Filtered反序列化

PHP 7引入了Filtered unserialize()函数&#xff0c;以在对不受信任的数据上的对象进行反序列化时提供更好的安全性。 <?phpclass MyClass1 { public $obj1prop; }class MyClass2 {public $obj2prop;}$obj1new MyClass1();$obj1->obj1prop1;$obj2new MyClass2();$obj…

【java并发编程的艺术读书笔记】AQS队列同步器简介、实现自定义锁

AQS介绍 AQS&#xff08;AbstractQueuedSynchronizer&#xff09;是 Java 并发包&#xff08;java.util.concurrent&#xff09;中一个重要的基础类&#xff0c;用于实现同步器&#xff08;Synchronizer&#xff09;的框架。AQS 提供了一种基于 FIFO 等待队列的机制&#xff0…