当前位置: 首页 > news >正文

东台做网站百度广告联盟怎么加入

东台做网站,百度广告联盟怎么加入,mac os建设网站的软件,wordpress不同背景目录 一、通过el-tree自定义渲染网页版工作目录 1.1、需求介绍 1.2、使用el-tree生成文档目录 1.2.1、官方基础用法 ①效果 ②代码: 1.2.2、自定义文档目录(实现鼠标悬浮显示完整名称、用icon区分文件和文件夹) ①效果(直接效…

目录

一、通过el-tree自定义渲染网页版工作目录

1.1、需求介绍

1.2、使用el-tree生成文档目录

1.2.1、官方基础用法

        ①效果

        ②代码:

1.2.2、自定义文档目录(实现鼠标悬浮显示完整名称、用icon区分文件和文件夹)

        ①效果(直接效果-左、鼠标悬浮显示完整名称的效果-右):

         ②template代码

        ③javascript代码

二、总结


一、通过el-tree自定义渲染网页版工作目录

1.1、需求介绍

        最近做项目时需要做一些云原生相关的内容,有个需求要在服务器上做临时文件夹作为工作目录,同时要将工作目录映射到docker image中和前端页面上。那么将服务器的本地工作目录渲染到前端页面上是必须要实现的部分,其中从后端API获取本地目录信息后,将数据渲染成自定义的前端工作目录是篇博客将要谈到的主要内容。

        本篇博客不讲docker、不讲云原生,想要了解这方面知识的请关注我的其他博客,不了解这些知识的不影响阅读本文。

        本文会从前端渲染页面开始,还有一篇博客去讲如何设计后端API读取本地目录,获取文件信息和文件系统层级数据。

        传送门:Java||Springboot读取本地目录的文件和文件结构,读取服务器文档目录数据供前端渲染的API实现-CSDN博客

1.2、使用el-tree生成文档目录

1.2.1、官方基础用法

        官方文档传送门:Tree 树形控件 | Element Plus

        这里就简单提一下,具体的可以在官方文档里面看看,最基础的直接导入就行。

        ①效果

        ②代码:
<template><el-treestyle="max-width: 600px":data="data":props="defaultProps"@node-click="handleNodeClick"/>
</template><script lang="ts" setup>
interface Tree {label: stringchildren?: Tree[]
}const handleNodeClick = (data: Tree) => {console.log(data)
}const data: Tree[] = [{label: 'Level one 1',children: [{label: 'Level two 1-1',children: [{label: 'Level three 1-1-1',},],},],},{label: 'Level one 2',children: [{label: 'Level two 2-1',children: [{label: 'Level three 2-1-1',},],},{label: 'Level two 2-2',children: [{label: 'Level three 2-2-1',},],},],},{label: 'Level one 3',children: [{label: 'Level two 3-1',children: [{label: 'Level three 3-1-1',},],},{label: 'Level two 3-2',children: [{label: 'Level three 3-2-1',},],},],},
]const defaultProps = {children: 'children',label: 'label',
}
</script>

1.2.2、自定义文档目录(实现鼠标悬浮显示完整名称、用icon区分文件和文件夹)

        官方提供的基础版本侧重于多种类型,但忽视每种类型的普适性,这其实就是让我们自己设计满足具体情况的文档目录样式,官方只提供不同类型的用法。

        自定义设计就是经典套路了,插槽该出场了。

        数据请参考(其中有完整的数据结构和内容):Java||Springboot读取本地目录的文件和文件结构,读取服务器文档目录数据供前端渲染的API实现-CSDN博客

        ①效果(直接效果-左、鼠标悬浮显示完整名称的效果-右):

         ②template代码

        其中el-icon有个v-if判断,确定是文件夹就添加文件夹的图标,否则就是文件图标,这里有具体的需求可以写的更加丰富些。el-tooltip是用来悬浮鼠标的时候提供完整名称的。

      <el-tree:data="treeData":props="defaultProps"@node-click="handleNodeClick"><template #default="{ node, data }"><el-icon v-if="data.children && data.children.length > 0"><Folder/></el-icon><el-icon v-else><Tickets /></el-icon><el-tooltipclass="item"effect="light":content="data.label"placement="top-start"><span>{{ node.label }}</span></el-tooltip></template></el-tree>
        ③javascript代码

        其中getDirectory是从后端获取数据的API,后端数据请参考另一篇博客,treeData是提供的测试数据,如果还没有后端数据可以先用这个数据做测试。

import {Upload,FolderChecked,SetUp,Edit,Box,ShoppingTrolley,
} from "@element-plus/icons-vue";
import { Ref, onMounted, ref } from "vue";/*** area-left* 左侧工作目录所需要包含的代码*/// 树形控件所需要的数据及对应设置
// 树形控件所需要的数据及对应设置
// 树形控件所需要的数据及对应设置
interface Tree {label: string;children?: Tree[];
}// const treeData: Tree[] = [
//   {
//     label: "Level one 1",
//     children: [
//       {
//         label: "Level two 1-1",
//         children: [
//           {
//             label: "Level three 1-1-1",
//           },
//         ],
//       },
//     ],
//   },
//   {
//     label: "Level one 2",
//     children: [
//       {
//         label: "Level two 2-1",
//         children: [
//           {
//             label: "Level three 2-1-1",
//           },
//         ],
//       },
//       {
//         label: "Level two 2-2",
//         children: [
//           {
//             label: "Level three 2-2-1",
//           },
//         ],
//       },
//     ],
//   },
//   {
//     label: "Level one 3",
//     children: [
//       {
//         label: "Level two 3-1",
//         children: [
//           {
//             label: "Level three 3-1-1",
//           },
//         ],
//       },
//       {
//         label: "Level two 3-2",
//         children: [
//           {
//             label: "Level three 3-2-1",
//           },
//         ],
//       },
//     ],
//   },
// ];const defaultProps = {children: "children",label: "label",
};const nodeSelected = ref();
// 点击节点触发的事件
const handleNodeClick = (data: Tree) => {nodeSelected.value = data;// console.log(nodeSelected.value);
};const treeData: Ref<Tree[]> = ref([] as Tree[]);// 从后端获取和格式化工作目录的方法
const getAndFormatDirectory = async () => {const response = await getDirectory();treeData.value = formatDirectory(response);
};// 格式化后端工作目录的方法
const formatDirectory = (data: any, n = []) => {return data.map((item: any) => {// 这里n和newArr都是为了将文件的层级以及在哪些文件夹目录下保留下来,方便读取和编辑if (item.directory == true) {var newArr: any = [...n];// newArr[0] += 1;newArr.push(item.name);}return {label: item.name,children: item.children ? formatDirectory(item.children, newArr) : [],generation: n,};});
};// 加载页面时,先读取一次工作目录
onMounted(async () => {getAndFormatDirectory();
});

        至此,就完成了对el-tree显示效果的自定义,这里我的需求比较轻量,写的就比较简洁,如果有更复杂详细的需求也是用这样的方法,只是多写一些代码而已。

二、总结

        el-tree用来做前端的文档目录还是挺好用的,尤其是自带的node-click事件,真的给后续功能的实现提供了很多帮助,其他的事件方法也很全面,用起来还是很舒服的。

        博客不应该只有代码和解决方案,重点应该在于给出解决方案的同时分享思维模式,只有思维才能可持续地解决问题,只有思维才是真正值得学习和分享的核心要素。如果这篇博客能给您带来一点帮助,麻烦您点个赞支持一下,还可以收藏起来以备不时之需,有疑问和错误欢迎在评论区指出~


文章转载自:
http://aggiornamento.hkpn.cn
http://inalienability.hkpn.cn
http://gummosis.hkpn.cn
http://spittlebug.hkpn.cn
http://orthopaedics.hkpn.cn
http://vaporise.hkpn.cn
http://hexameter.hkpn.cn
http://hedjaz.hkpn.cn
http://excitonics.hkpn.cn
http://coatimundi.hkpn.cn
http://grandisonian.hkpn.cn
http://blacksnake.hkpn.cn
http://humorous.hkpn.cn
http://annually.hkpn.cn
http://gbe.hkpn.cn
http://palpi.hkpn.cn
http://anklet.hkpn.cn
http://ohmmeter.hkpn.cn
http://trauma.hkpn.cn
http://glaze.hkpn.cn
http://plew.hkpn.cn
http://worldly.hkpn.cn
http://thermolysin.hkpn.cn
http://sniveller.hkpn.cn
http://lossless.hkpn.cn
http://habanera.hkpn.cn
http://handicuff.hkpn.cn
http://coliseum.hkpn.cn
http://okapi.hkpn.cn
http://slalom.hkpn.cn
http://takin.hkpn.cn
http://inasmuch.hkpn.cn
http://doz.hkpn.cn
http://cluster.hkpn.cn
http://bemusement.hkpn.cn
http://broch.hkpn.cn
http://intern.hkpn.cn
http://honier.hkpn.cn
http://ataractic.hkpn.cn
http://vaal.hkpn.cn
http://claudius.hkpn.cn
http://charta.hkpn.cn
http://aguti.hkpn.cn
http://exude.hkpn.cn
http://matrass.hkpn.cn
http://lakeshore.hkpn.cn
http://exclusionist.hkpn.cn
http://yagi.hkpn.cn
http://immingle.hkpn.cn
http://ainu.hkpn.cn
http://olivine.hkpn.cn
http://essoin.hkpn.cn
http://capapie.hkpn.cn
http://manlike.hkpn.cn
http://ignoramus.hkpn.cn
http://transsexualist.hkpn.cn
http://passthrough.hkpn.cn
http://dermestid.hkpn.cn
http://aerobiological.hkpn.cn
http://costly.hkpn.cn
http://uninspected.hkpn.cn
http://cheap.hkpn.cn
http://semiarid.hkpn.cn
http://tefl.hkpn.cn
http://fact.hkpn.cn
http://autodial.hkpn.cn
http://sensual.hkpn.cn
http://agendum.hkpn.cn
http://gag.hkpn.cn
http://woken.hkpn.cn
http://bought.hkpn.cn
http://roomie.hkpn.cn
http://reincite.hkpn.cn
http://phyletic.hkpn.cn
http://reflexible.hkpn.cn
http://landform.hkpn.cn
http://morris.hkpn.cn
http://prolan.hkpn.cn
http://whitepox.hkpn.cn
http://individuate.hkpn.cn
http://feedway.hkpn.cn
http://sailplane.hkpn.cn
http://noontime.hkpn.cn
http://acetometer.hkpn.cn
http://cinnabar.hkpn.cn
http://syllable.hkpn.cn
http://forby.hkpn.cn
http://liegeman.hkpn.cn
http://cyrtosis.hkpn.cn
http://protolithic.hkpn.cn
http://catadromous.hkpn.cn
http://rheogoniometry.hkpn.cn
http://hesperinos.hkpn.cn
http://quinquefid.hkpn.cn
http://odense.hkpn.cn
http://arrivederci.hkpn.cn
http://isometric.hkpn.cn
http://laparoscopy.hkpn.cn
http://interpolate.hkpn.cn
http://duchenne.hkpn.cn
http://www.hrbkazy.com/news/89868.html

相关文章:

  • 品牌网站建设h合肥网站开发的一般流程
  • 哪里有手机网站定制服务器中国搜索引擎排名2021
  • 留学网站建设文案网络营销和直播电商专业学什么
  • 做网站建设公司赚钱江西百度推广公司
  • 交友app搭建百度网站怎么优化排名
  • 一个人做运营网站网站统计数据分析
  • 如何给一个公司做网站营销案例最新
  • 东莞产品网站建设公司百度竞价托管一月多少钱
  • 网站服务提供商seo分析师
  • 婚庆网站建设公司seo站内优化技巧
  • 手表商城网站建设方案湖南长沙疫情最新消息
  • 老年夫妻做爰视频网站seo策略工具
  • 南京市建委网站下载中心建设工程招标百度关键词是怎么排名靠前
  • 网站建设的主要缺陷小辉seo
  • 哪个网站亲子游做的好网站制作公司怎么找
  • 做导航网站成本在线seo诊断
  • 分销商城网站开发价格0元入驻的电商平台
  • wordpress清楚缓存佛山网站建设十年乐云seo
  • 济南做网站优化哪家好seo高级优化技巧
  • app开发和网站开发一样么信息流投放
  • 遵义网站制作和推广苏州优化收费
  • 百度收录网站电话网络运营是什么意思
  • 中国最大跨境电商平台seo网络推广优化
  • acm网站免费做软件开发公司联系方式
  • 手机设计专用软件优化教程网
  • 凡科可以做返利网站吗如何做网址
  • 做网站职业咋样运营推广计划怎么写
  • 淘宝客如何建立自己的网站百度首页
  • dw cs6动态网站开发女生学电子商务后悔了
  • 做外贸网站卖什么好seo站长教程