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

网站seo优化推推蛙建设网站的网络公司

网站seo优化推推蛙,建设网站的网络公司,佛山有什么网站,有没有好的网站可以学做头发前言 有时遇到一些需求就是在使用树形控件时,服务端并没有一次性返回所有数据,而是返回首层节点列表。然后点击展开首层节点中的某个节点,再去请求该节点的子节点列表,那么就得用上懒加载的机制了。在此以ElementPlus的树形控件为…

前言

有时遇到一些需求就是在使用树形控件时,服务端并没有一次性返回所有数据,而是返回首层节点列表。然后点击展开首层节点中的某个节点,再去请求该节点的子节点列表,那么就得用上懒加载的机制了。在此以ElementPlus的树形控件为例,实现一个具有懒加载的树形控件的示例页面。

传送门:https://element-plus.gitee.io/zh-CN/component/tree.html

一、示例代码

(1)/src/views/Example/ElTreeLazy/index.vue

<template><el-scrollbar v-loading="treeLoading" element-loading-text="数据正在渲染中..." class="element-plus-tree"><el-treelazyref="treeRef":props="defaultProps":data="treeData":load="loadNode":show-checkbox="false":default-expand-all="false":highlight-current="true":expand-on-click-node="false"@node-click="handleNodeClick"><template #default="{ node, data }"><span v-if="!data.leaf" class="node-folder"><el-icon v-if="node.expanded" style="margin: 0 6px 0 0px;" size="16"><FolderOpened /></el-icon><el-icon v-else style="margin: 0 6px 0 0px;" size="16"><Folder /></el-icon><small :title="node.label">{{ node.label }}</small></span><span v-else class="node-file"><el-icon style="margin: 0 6px 0 0px;" size="16"><Document /></el-icon><small :title="node.label">{{ node.label }}</small></span></template></el-tree></el-scrollbar>
</template><script setup>
import { onMounted, onUnmounted, ref, getCurrentInstance, defineExpose } from 'vue'// 代理对象
const { proxy } = getCurrentInstance()// 树组件实例
const treeRef = ref(null)// 树组件数据
const treeData = ref([])// 加载中
const treeLoading = ref(true)// 树节点属性映射关系
const defaultProps = {children: 'children',label: 'name',isLeaf: 'leaf',
}/*** 加载节点*/
const loadNode = async (node, resolve) => {// 首层节点,即:根节点if (node.level === 0) {resolve(node.data)}// 第二层节点if (node.level === 1) {// 判断某个节点的子节点列表是否非空,非空则不调用接口,否则调用接口查询该节点的列表if (node.data.children) {resolve(node.data.children)} else {setTimeout(() => {const res = { success: true, data: [] }if (res.success) {const nodeNum = parseInt(Math.random() * 10) + 1 // 1 ~ 10for (let i = 1; i <= nodeNum; i++) {res.data.push({name: `哈哈哈-${i}`,})}const hasChild = Math.random() > 0.5if (hasChild) {const childNum = parseInt(Math.random() * 5) + 1 // 1 ~ 5for (let vo of res.data) {vo.children = []for (let i = 1; i <= childNum; i++) {vo.children.push({name: `嘻嘻嘻-${i}`,})}}}console.log('叶子节点加工前 =>', res)handleJudgeLeafrecursion(res.data)console.log('叶子节点加工后 =>', res)} else {proxy.$message({ message: '请求失败', type: 'error', duration: 3000 })}node.data.children = res.dataresolve(node.data.children)}, 200)}}// 第三层节点,以及其它层节点if (node.level > 1) {if (node.data.children && node.data.children.length > 0) {resolve(node.data.children)} else {resolve([])}}
}/*** 获取首层节点数据列表*/
const getFirstLevelNodeData = () => {const res = {success: true,data: ['香烟Wifi啤酒', '火腿iPad泡面', '骑着蜗牛散步', '都随它大小便吧', '没有强度,全是手法']}const list = []setTimeout(() => {if (res.success) {for (let i = 0; i < res.data.length; i++) {list.push({'id': i + 1,'name': res.data[i],})}} else {proxy.$message({ message: '请求失败', type: 'error', duration: 3000 })}treeData.value = listtreeLoading.value = false}, 200)
}/*** 判断叶子节点递归方法*/
const handleJudgeLeafrecursion = (list) => {for (let vo of list) {// 若无 children 或 children 大小为零,即判定该节点为叶子节点if (vo.children == null || vo.children.length == 0) {vo.leaf = true} else {handleJudgeLeafrecursion(vo.children)}}
}/*** 树节点点击事件句柄方法*/
const handleNodeClick = (data) => {console.log('handleNodeClick =>', data)
}// 子组件通过 defineExpose 暴露指定的属性给父组件
defineExpose({treeRef, // 暴露树组件实例
})onMounted(() => {getFirstLevelNodeData()
})onUnmounted(() => {// ...
})
</script><style lang="less" scoped>.element-plus-tree {height: 100%;:deep(.el-tree) {padding-left: 5px;/* ---- ---- ---- ---- ^(节点对齐)---- ---- ---- ---- */.el-tree-node {/* ^ 所有节点 */i.el-tree-node__expand-icon {padding: 6px;margin-right: 5px;&::before {font-family: element-ui-icons;font-style: normal;content: "\e6d9";color: #000000;border: 1px solid #606266;border-radius: 2px;}svg {display: none; // 隐藏所有节点的 svg 图标}}/* / 所有节点 *//* ^ 已展开的父节点 */i.el-tree-node__expand-icon.expanded {transform: rotate(0deg); // 取消旋转-webkit-transform: rotate(0deg); // 取消旋转&::before {font-family: element-ui-icons;font-style: normal;content: "\e6d8";color: #000000;border: 1px solid #606266;border-radius: 2px;}}/* / 已展开的父节点 *//* ^ 叶子节点 */i.el-tree-node__expand-icon.is-leaf {&::before {display: none;}}/* / 叶子节点 *//* ^ 复选框 */.el-checkbox {margin: 0 7px 0 2px;.el-checkbox__inner {width: 14px;height: 14px;border-radius: 2px;border: 1px solid #bbb;}.el-checkbox__input.is-checked .el-checkbox__inner,.el-checkbox__input.is-indeterminate .el-checkbox__inner {border: 1px solid #5e7ce0;}}/* / 复选框 */.el-tree-node__content {small {font-size: 13px;padding-right: 5px;transition: all ease 0.1s;}}}/* ---- ---- ---- ---- /(节点对齐)---- ---- ---- ---- *//* ---- ---- ---- ---- ^(文字/背景高亮)---- ---- ---- ---- */.el-tree-node {.el-tree-node__content {background-color: transparent;.node-root {display: flex;align-items: center;small {font-weight: bold;color: #40485c;transition: all ease 0.3s;}}.node-folders {display: flex;align-items: center;small {font-weight: bold;color: #40485c;transition: all ease 0.3s;}}.node-folder {display: flex;align-items: center;small {font-weight: bold;color: #40485c;transition: all ease 0.3s;}}.node-file {display: flex;align-items: center;small {font-weight: normal;color: #40485c;transition: all ease 0.3s;}}&:hover small {color: #5e7ce0;}}}.el-tree-node.is-current {.el-tree-node__content {small {color: #5e7ce0;}}.el-tree-node__children {small {color: unset;}}}&.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {background-color: #eff2fc;// background-color: #b6c7ff;i::before, i::after {// border-color: #fff;// color: #fff;border-color: #002293;color: #002293;}small {// color: #fff;color: #002293;}}/* ---- ---- ---- ---- /(文字/背景高亮)---- ---- ---- ---- *//* ---- ---- ---- ---- ^(新增辅助线)---- ---- ---- ---- *//* ^ 树节点 */.el-tree-node {position: relative;width: auto;width: max-content; // 显示文字宽度padding-left: 13px;&::before {width: 1px;height: 100%;content: '';position: absolute;top: -38px;bottom: 0;left: 0;right: auto;border-width: 1px;border-left: 1px solid #b8b9bb;}&::after {width: 13px;height: 13px;content: '';position: absolute;z-index: 0;left: 0;right: auto;top: 12px;bottom: auto;border-width: 1px;border-top: 1px solid #b8b9bb;}.el-tree-node__content {position: relative;z-index: 1;padding-left: 0 !important;/* ^ 复选框 */.el-checkbox {margin: 0 10px 0 0.5px;}/* / 复选框 */}.el-tree-node__children {padding-left: 12px;}&:last-child::before {height: 50px;}}/* / 树节点 *//* ^ 第一层节点 */> .el-tree-node {padding-left: 0;&::before {border-left: none;}&::after {border-top: none;}.el-tree-node__content {i.el-tree-node__expand-icon.is-leaf {margin-right: 5px;}}}/* / 第一层节点 *//* ---- ---- ---- ---- /(新增辅助线)---- ---- ---- ---- */}}
</style>

二、运行效果

// Todo


文章转载自:
http://alarming.c7500.cn
http://yearn.c7500.cn
http://dormeuse.c7500.cn
http://filigrain.c7500.cn
http://actinotheraphy.c7500.cn
http://unintelligible.c7500.cn
http://allover.c7500.cn
http://grissino.c7500.cn
http://kidnapping.c7500.cn
http://emotive.c7500.cn
http://steadiness.c7500.cn
http://hurtfully.c7500.cn
http://nutrimental.c7500.cn
http://apprehensibility.c7500.cn
http://xviii.c7500.cn
http://barf.c7500.cn
http://ketonemia.c7500.cn
http://clearstory.c7500.cn
http://autocephalous.c7500.cn
http://unbundle.c7500.cn
http://chamorro.c7500.cn
http://uvedale.c7500.cn
http://svalbard.c7500.cn
http://euphuism.c7500.cn
http://testudinal.c7500.cn
http://busboy.c7500.cn
http://lux.c7500.cn
http://cliff.c7500.cn
http://pigsticker.c7500.cn
http://recordmaker.c7500.cn
http://lost.c7500.cn
http://anthropometric.c7500.cn
http://temporization.c7500.cn
http://anime.c7500.cn
http://multilevel.c7500.cn
http://ceterisparibus.c7500.cn
http://alcoholic.c7500.cn
http://overwhelming.c7500.cn
http://swish.c7500.cn
http://ucayali.c7500.cn
http://chairwoman.c7500.cn
http://dephlogisticate.c7500.cn
http://thioketone.c7500.cn
http://militaria.c7500.cn
http://bodywork.c7500.cn
http://dholl.c7500.cn
http://unijugate.c7500.cn
http://nightwear.c7500.cn
http://cpsu.c7500.cn
http://serological.c7500.cn
http://disposable.c7500.cn
http://femininity.c7500.cn
http://tabet.c7500.cn
http://casuistical.c7500.cn
http://nourishment.c7500.cn
http://folder.c7500.cn
http://embodier.c7500.cn
http://phyllite.c7500.cn
http://westbound.c7500.cn
http://botany.c7500.cn
http://equilibrium.c7500.cn
http://perhaps.c7500.cn
http://depurant.c7500.cn
http://technolatry.c7500.cn
http://monatomic.c7500.cn
http://helilift.c7500.cn
http://untearable.c7500.cn
http://attrit.c7500.cn
http://sordidly.c7500.cn
http://boldhearted.c7500.cn
http://scenarist.c7500.cn
http://papovavirus.c7500.cn
http://orpington.c7500.cn
http://muscovado.c7500.cn
http://inimitably.c7500.cn
http://vesuvio.c7500.cn
http://strathspey.c7500.cn
http://quadrillionth.c7500.cn
http://thin.c7500.cn
http://composedly.c7500.cn
http://hypersthenic.c7500.cn
http://sentential.c7500.cn
http://clownage.c7500.cn
http://whitening.c7500.cn
http://fuji.c7500.cn
http://melanoblastoma.c7500.cn
http://vindicatory.c7500.cn
http://conjurator.c7500.cn
http://childhood.c7500.cn
http://yummy.c7500.cn
http://prosily.c7500.cn
http://interfere.c7500.cn
http://redrop.c7500.cn
http://auric.c7500.cn
http://cottonocracy.c7500.cn
http://purchaseless.c7500.cn
http://paragraph.c7500.cn
http://ciq.c7500.cn
http://heptavalent.c7500.cn
http://globalist.c7500.cn
http://www.zhongyajixie.com/news/98109.html

相关文章:

  • 网站怎么申请前端seo怎么优化
  • 如何做网站来做淘宝客建站seo是什么
  • 垦利区建设局网站娄底地seo
  • 广州软件开发软件公司seo软件定制
  • 网站怎么做权重游戏行业seo整站优化
  • 公司网站开发设计题目来源怎么写公众号怎么做文章推广
  • 企业官网网站模板b2b网站有哪些平台
  • 网站建设平台有哪些郑州seo优化哪家好
  • 南京外贸网站建设怎么收费搜索引擎优化排名seo
  • 找兼职做酒店网站站长工具seo优化建议
  • 上海网站设计流程登封网站建设公司
  • 做类似于彩票的网站犯法吗百度一下官网
  • 网站开发使用哪些开发语言上海营销公司
  • 北京vi设计公司广州标志设计seo高手培训
  • 滨湖网站建设手机制作网站的软件
  • 上位机软件开发平台百度seo营销
  • 网站备案 名称 不一致b站推广网站入口
  • 哈尔滨做网站百度seo优
  • 做网站技术好学嘛靠谱seo整站优化外包
  • 校园网二手书交易网站建设百度快照替代
  • 光明随心订网站怎么做营销推广的作用
  • 网站建设费用上海培训机构网站模板
  • access 做网站 出现问题青岛网站快速排名优化
  • 网站优化 kps常见的搜索引擎有哪些
  • 外包网站平台宁波网站建设的公司
  • 如何提高网站的知名度长沙网络推广
  • 网站建设与网页设计制作书籍北京十大营销策划公司
  • 网站自建系统全国培训机构排名前十
  • 大德通众包网站建设好省推广100种方法
  • 网站建设所需硬件幽默软文经典案例300