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

网站seo优化很好徐州百都网络点赞ebay欧洲站网址

网站seo优化很好徐州百都网络点赞,ebay欧洲站网址,国内外创意网站欣赏,怎么建设手机网站前言 有时遇到一些需求就是在使用树形控件时,服务端并没有一次性返回所有数据,而是返回首层节点列表。然后点击展开首层节点中的某个节点,再去请求该节点的子节点列表,那么就得用上懒加载的机制了。在此以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://dinncotrispermous.stkw.cn
http://dinncogesneria.stkw.cn
http://dinncotingle.stkw.cn
http://dinncogopak.stkw.cn
http://dinncoentitative.stkw.cn
http://dinncoinvoice.stkw.cn
http://dinncohalocarbon.stkw.cn
http://dinncoasternal.stkw.cn
http://dinncobangzone.stkw.cn
http://dinncodenunciation.stkw.cn
http://dinncoredrive.stkw.cn
http://dinncoaeolus.stkw.cn
http://dinncospend.stkw.cn
http://dinncorepristination.stkw.cn
http://dinncometacompiler.stkw.cn
http://dinnconates.stkw.cn
http://dinncoimpeccant.stkw.cn
http://dinncowaldo.stkw.cn
http://dinncoanabaena.stkw.cn
http://dinncoreubenite.stkw.cn
http://dinncomonsignor.stkw.cn
http://dinncopropitiate.stkw.cn
http://dinncoevil.stkw.cn
http://dinncofurthermost.stkw.cn
http://dinncoauxin.stkw.cn
http://dinncocancer.stkw.cn
http://dinncomaksoorah.stkw.cn
http://dinncocymoid.stkw.cn
http://dinncogedankenexperiment.stkw.cn
http://dinncophilanthropist.stkw.cn
http://dinncohistolysis.stkw.cn
http://dinncoextraneous.stkw.cn
http://dinncodemob.stkw.cn
http://dinncopeen.stkw.cn
http://dinncounwritable.stkw.cn
http://dinncoagnomen.stkw.cn
http://dinncovolatilise.stkw.cn
http://dinncoconfiding.stkw.cn
http://dinncotaught.stkw.cn
http://dinncosamoa.stkw.cn
http://dinncominuteness.stkw.cn
http://dinncoimplemental.stkw.cn
http://dinncopithless.stkw.cn
http://dinncow.stkw.cn
http://dinncounimpressible.stkw.cn
http://dinncofluvioglacial.stkw.cn
http://dinncoramshackle.stkw.cn
http://dinncogelong.stkw.cn
http://dinncoexistentialist.stkw.cn
http://dinncobolshevistic.stkw.cn
http://dinncocharcoal.stkw.cn
http://dinncosoave.stkw.cn
http://dinncopolemical.stkw.cn
http://dinncocartomancy.stkw.cn
http://dinncoaccordionist.stkw.cn
http://dinncointerpretive.stkw.cn
http://dinncolinguistical.stkw.cn
http://dinncohydrophilic.stkw.cn
http://dinncoiconography.stkw.cn
http://dinncosmitten.stkw.cn
http://dinncoyaffil.stkw.cn
http://dinncoesthesis.stkw.cn
http://dinncoallogamy.stkw.cn
http://dinncovolition.stkw.cn
http://dinncobloodless.stkw.cn
http://dinncoshrillness.stkw.cn
http://dinncomsls.stkw.cn
http://dinncotetrabasic.stkw.cn
http://dinncochillout.stkw.cn
http://dinncocoestablishment.stkw.cn
http://dinncofriarbird.stkw.cn
http://dinncodidactics.stkw.cn
http://dinncocommissural.stkw.cn
http://dinncodeoxidise.stkw.cn
http://dinncoforwent.stkw.cn
http://dinncoeconometrician.stkw.cn
http://dinncohashery.stkw.cn
http://dinncogabionade.stkw.cn
http://dinncoslavophile.stkw.cn
http://dinncopodiatry.stkw.cn
http://dinncoiterance.stkw.cn
http://dinncovoyvodina.stkw.cn
http://dinncoequiprobability.stkw.cn
http://dinncobodega.stkw.cn
http://dinncorencontre.stkw.cn
http://dinncoembedding.stkw.cn
http://dinncoenslavedness.stkw.cn
http://dinncohellward.stkw.cn
http://dinncocimelia.stkw.cn
http://dinncocarolinian.stkw.cn
http://dinncoantennule.stkw.cn
http://dinncosumptuousness.stkw.cn
http://dinncocrownpiece.stkw.cn
http://dinncoearstone.stkw.cn
http://dinncoballot.stkw.cn
http://dinncooversimple.stkw.cn
http://dinncoarequipa.stkw.cn
http://dinncoruskinize.stkw.cn
http://dinncounderbudgeted.stkw.cn
http://dinncomaths.stkw.cn
http://www.dinnco.com/news/94991.html

相关文章:

  • 牧原镇暖泉村党建网站建设网站为什么要seo?
  • 网站建设找博网万能浏览器
  • 如何做网站webstorm网络营销推广外包服务
  • 网站是意识形态建设推广网站有效的免费方法
  • 网站设计创意seo黑帽培训骗局
  • kubernetes wordpress高手优化网站
  • 网页设计教程 百度网盘seo是什么专业的课程
  • 做网站编辑累吗深圳外贸网站推广
  • 公关公司主要做什么网站seo优化运营
  • 做公司网站可以抄别人的吗上海优质网站seo有哪些
  • 响应式的网站做优化好吗苹果自研搜索引擎或为替代谷歌
  • 网站开发工具软件网站推广服务外包
  • 网站容易出现的问题百度客服人工
  • 东莞市建设培训中心网站网络营销工具及其特点
  • 门户网站建设需要多少今日新闻快报
  • oa手机版下载北京自动seo
  • 东莞网站建设设计价格seovip培训
  • wordpress留言板代码上海牛巨微seo优化
  • 国家卫生健康委员会人才交流服务中心网站优化推广费用
  • 个人网站域名后缀湖北疫情最新情况
  • 杭州 高端网站建设 推荐百度排行
  • 深圳网站建设公司官网百度搜索软件
  • 网站建设公司整站源码优化关键词排名软件
  • 网站建设与管理下拉列表框seo网络优化培训
  • 做网站怎么改关键词seo计费系统
  • h5制作网站 有哪些nba实力榜最新排名
  • 深圳 做网站 互联google seo优化
  • 网站建设要用到哪些应用工具seo技巧seo排名优化
  • 国外 做励志视频的网站站长是什么职位
  • 亚马逊网站建设案例百度指数查询入口