vue数据转树状结构进阶(两级父节点)

2024-01-25 04:10

本文主要是介绍vue数据转树状结构进阶(两级父节点),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

需求:不仅按照项目还要按照教师名称

let dataX = [{"uuid": "04991AB0ED31413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": "气象课1","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "be083f6f10bc4168b6d04106f14b5b68","evalStatus": "0","saveTime": "2023-09-05 16:19:38"},{"uuid": "04991AB0ED36413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": "气象课1","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "65f9ced819a74c879c640082772383d6","evalStatus": "0","saveTime": "2023-09-05 16:19:38"},{"uuid": "04991AB0ED35413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": "气象课1","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "23b7e94695ef49cc860ca32fd60d795d","evalStatus": "0","saveTime": "2023-09-05 16:19:38"},{"uuid": "04991AB0ED34413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": "气象课1","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "81686d4bf5684f57a2a55b275527b02b","evalStatus": "0","saveTime": "2023-09-05 16:19:38"},{"uuid": "04991AB0ED33413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": "气象课1","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "d0a8c90d5e1746f6a6aa279136a3ee0d","evalStatus": "0","saveTime": "2023-09-05 16:19:38"},{"uuid": "04991AB0ED30413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": null,"courseTime": "2023-09-01 08:30-09:15","resourceId": null,"resourceName": null,"sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 10.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 3.0,"theoryPracticeRemark": null,"instruct": 20.0,"instructRemark": null,"useSample": 1.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 84.0,"evalRemark": "李宁哦哦","evalId": "002E0518DD5074F2E065000000000001","evalStatus": "1","saveTime": "2023-09-05 16:19:38"},{"uuid": "04991AB0ED32413EE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "eab61e92f937437caf94f4928d21fb2d","projName": "TEST0901_0928","trainId": "0901_0928","courseId": null,"courseName": "气象课1","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "403ab08d05f44c9d84e479fe0f1f0d8a","evalStatus": "0","saveTime": "2023-09-05 16:19:38"},{"uuid": "036A074BBF947EABE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "dcf44c6f3cde454fa50116aebff08b6e","projName": "测试0821","trainId": "px-2023-0821","courseId": null,"courseName": null,"courseTime": "2023-08-21 08:30-16:15","resourceId": "02ED47ECE717763CE065000000000001","resourceName": "管训楼107","sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 10.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 10.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 1.0,"classTimeRemark": null,"comEvaluation": 81.0,"evalRemark": "sdsd","evalId": "d54d97c1550c422ca0e163c132389ee5","evalStatus": "1","saveTime": "2023-08-21 14:35:23"},{"uuid": "036A074BBF927EABE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "dcf44c6f3cde454fa50116aebff08b6e","projName": "测试0821","trainId": "px-2023-0821","courseId": null,"courseName": "气象课","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "F6D8BE2B9FCD6B8AE055000000000001","evalStatus": "0","saveTime": "2023-08-21 14:35:23"},{"uuid": "036A074BBF937EABE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "dcf44c6f3cde454fa50116aebff08b6e","projName": "测试0821","trainId": "px-2023-0821","courseId": null,"courseName": "气象课","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "fec1d3cb91cc4dc89a38d4b2935a6e93","evalStatus": "0","saveTime": "2023-08-21 14:35:23"},{"uuid": "036A074BBF957EABE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "dcf44c6f3cde454fa50116aebff08b6e","projName": "测试0821","trainId": "px-2023-0821","courseId": null,"courseName": "气象课","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "adb8d5b000164402b853d6f2f40b7b95","evalStatus": "0","saveTime": "2023-08-21 14:35:23"},{"uuid": "036A074BBF967EABE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "dcf44c6f3cde454fa50116aebff08b6e","projName": "测试0821","trainId": "px-2023-0821","courseId": null,"courseName": "气象课","courseTime": null,"resourceId": null,"resourceName": null,"sense": null,"senseRemark": null,"preLesson": null,"preLessonRemark": null,"familiarity": null,"familiarityRemark": null,"importance": null,"importanceRemark": null,"theoryPractice": null,"theoryPracticeRemark": null,"instruct": null,"instructRemark": null,"useSample": null,"useSampleRemark": null,"methods": null,"methodsRemark": null,"classTime": null,"classTimeRemark": null,"comEvaluation": null,"evalRemark": null,"evalId": "236690bf31504e9f85b3c442a843fa7d","evalStatus": "0","saveTime": "2023-08-21 14:35:23"},{"uuid": "028A0F7F209E546DE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "e90a05335e584824947cb8cd4ad461e0","projName": "测试0809","trainId": "0809","courseId": null,"courseName": null,"courseTime": "2023-08-10 08:30-10:15","resourceId": "F8A2B4EE72586516E055000000000001","resourceName": "训练楼103","sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 10.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 10.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 0.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 80.0,"evalRemark": "fvdsgsdfg","evalId": "002E0518DD5074F2E065000000000001","evalStatus": "1","saveTime": "2023-08-10 11:19:14"},{"uuid": "0176C00FA5180EE9E065000000000001","teacherId": "f9dde5be35844417ac9cc6aabc0234d5","teacherName": "陆虎","planId": "a10aee22727848e8af8010f954df2241","projName": "测试0710","trainId": "Test-0710","courseId": null,"courseName": null,"courseTime": "2023-03-21 08:30-16:15","resourceId": null,"resourceName": null,"sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 0.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 0.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 70.0,"evalRemark": "gdsg","evalId": "002E0518DD5074F2E065000000000001","evalStatus": "1","saveTime": "2023-07-27 19:03:00"},{"uuid": "00692761019E04EAE065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "f590b85ba0a944e381514386298c4038","projName": "2023第4期气象培训","trainId": "PX-2023-04","courseId": null,"courseName": "F82C91AFB3781D54E055000000000001","courseTime": "2023-07-24 08:30-09:15","resourceId": "F8A2B4EE72586516E055000000000001","resourceName": "训练楼103","sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 10.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 10.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 90.0,"evalRemark": null,"evalId": "002E0518DD5074F2E065000000000001","evalStatus": "1","saveTime": "2023-07-14 09:13:17"},{"uuid": "005DCEF6927C1A65E065000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "db6a0ef66dcd4e57afa4af49f7a1081f","projName": "2023第1期培训","trainId": "PX-2023-01","courseId": null,"courseName": "F82C91AFB3781D54E055000000000001","courseTime": "2023-08-01 08:30-10:15","resourceId": "F8A2B4EE72586516E055000000000001","resourceName": "训练楼103","sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 10.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 10.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 90.0,"evalRemark": null,"evalId": "002E0518DD5074F2E065000000000001","evalStatus": "1","saveTime": "2023-07-13 19:41:09"},{"uuid": "FF43EE3BC4F05CC4E055000000000001","teacherId": "f9dde5be35844417ac9cc6aabc0234d5","teacherName": "陆虎","planId": "4cf36ce4c8e542b0ae0d111ff2a85ae7","projName": "测试0629","trainId": "test-0629","courseId": null,"courseName": "F842FE12AF2E317DE055000000000001","courseTime": "2023-06-26 08:30-10:15","resourceId": "F8A2B4EE72586516E055000000000001","resourceName": "训练楼103","sense": 10.0,"senseRemark": null,"preLesson": 8.0,"preLessonRemark": null,"familiarity": 8.0,"familiarityRemark": null,"importance": 9.0,"importanceRemark": null,"theoryPractice": 9.0,"theoryPracticeRemark": null,"instruct": 15.0,"instructRemark": null,"useSample": 9.0,"useSampleRemark": null,"methods": 8.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 86.0,"evalRemark": null,"evalId": "81686d4bf5684f57a2a55b275527b02b","evalStatus": "1","saveTime": "2023-06-29 20:09:48"},{"uuid": "FF43EE3BC4F15CC4E055000000000001","teacherId": "f9dde5be35844417ac9cc6aabc0234d5","teacherName": "陆虎","planId": "4cf36ce4c8e542b0ae0d111ff2a85ae7","projName": "测试0629","trainId": "test-0629","courseId": null,"courseName": "F842FE12AF2E317DE055000000000001","courseTime": "2023-06-26 08:30-10:15","resourceId": "F8A2B4EE72586516E055000000000001","resourceName": "训练楼103","sense": 10.0,"senseRemark": null,"preLesson": 9.0,"preLessonRemark": null,"familiarity": 8.0,"familiarityRemark": null,"importance": 7.0,"importanceRemark": null,"theoryPractice": 9.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 83.0,"evalRemark": null,"evalId": "23b7e94695ef49cc860ca32fd60d795d","evalStatus": "1","saveTime": "2023-06-29 20:09:48"},{"uuid": "FF4469B721DA734AE055000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "4cf36ce4c8e542b0ae0d111ff2a85ae7","projName": "测试0629","trainId": "test-0629","courseId": null,"courseName": "FD0CF1D6E5241FCEE055000000000001","courseTime": "2023-06-27 08:30-09:15","resourceId": "F8A2B4EE725A6516E055000000000001","resourceName": "管训楼102","sense": 10.0,"senseRemark": null,"preLesson": 9.0,"preLessonRemark": null,"familiarity": 8.0,"familiarityRemark": null,"importance": 8.0,"importanceRemark": null,"theoryPractice": 10.0,"theoryPracticeRemark": null,"instruct": 20.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 9.0,"classTimeRemark": null,"comEvaluation": 94.0,"evalRemark": null,"evalId": "23b7e94695ef49cc860ca32fd60d795d","evalStatus": "1","saveTime": "2023-06-29 19:58:05"},{"uuid": "FF4469B721D9734AE055000000000001","teacherId": "fd79ec5259364284875cb8e87a6cdda5","teacherName": "王菲","planId": "4cf36ce4c8e542b0ae0d111ff2a85ae7","projName": "测试0629","trainId": "test-0629","courseId": null,"courseName": "FD0CF1D6E5241FCEE055000000000001","courseTime": "2023-06-27 08:30-09:15","resourceId": "F8A2B4EE725A6516E055000000000001","resourceName": "管训楼102","sense": 10.0,"senseRemark": null,"preLesson": 10.0,"preLessonRemark": null,"familiarity": 10.0,"familiarityRemark": null,"importance": 10.0,"importanceRemark": null,"theoryPractice": 10.0,"theoryPracticeRemark": null,"instruct": 10.0,"instructRemark": null,"useSample": 10.0,"useSampleRemark": null,"methods": 10.0,"methodsRemark": null,"classTime": 10.0,"classTimeRemark": null,"comEvaluation": 90.0,"evalRemark": null,"evalId": "81686d4bf5684f57a2a55b275527b02b","evalStatus": "1","saveTime": "2023-06-29 19:58:05"}]
// 深拷贝
function deepClone(data) {let dataType = getDataType(data);let container;if (dataType === 'Object') {container = {};}if (dataType === 'Array') {container = [];}for (const key in data) {let type = getDataType(data[key]);if (key === 'Array' || type === 'Object') {container[key] = deepClone(data[key]);} else {container[key] = data[key];}}return container;
}
// 判断数据类型
function getDataType(data) {return Object.prototype.toString.call(data).slice(8, -1);
}
function addProAndTeach(data){// 添加一级父节点(project)var afterDeptList = []; // 找项目名var afterTeaData = []; // 将父节点添加进去for (let item of data) {if (!afterDeptList.includes(item.planId)) { // 如果这个项目id没有出现过,就把项目id第一个放进去afterDeptList.push(item.planId);let projName = item.projName + '(' + item.trainId + ')';// 添加一个该项目第一次出现的父节点afterTeaData.push({ uuid: item.planId, pid: '0', projName: projName, trainId: item.trainId, isParent: '1' });item.pid = item.planId;} else {item.pid = item.planId; //父节点出现了,给子节点添加一个索引}}data = [...afterTeaData, ...data];// 添加二级父节点(teacher)let result = [],teacherList = [];for (let item of data) {if (item.pid != '0') { // 如果pid不是0 那么说明有父节点let teacherId = item.teacherId;let planId = item.planId;let pid = planId + teacherId; // 项目名+teacher名if (teacherList.includes(pid)) {item.project = '';item.pid = planId + teacherId;item.projName = item.courseName;result.push(item);} else {teacherList.push(pid);result.push({ uuid: pid, pid: item.planId, projName: item.teacherName, isParent: '1' });//构造日期下的第一个节点let temp = deepClone(item);temp.pid = pid;temp.projName = temp.courseName;result.push(temp);}} else {result.push(item);}}return result
}let y = addProAndTeach(dataX)//自定义id,pid 转为树结构
function getDeptTreeCustom(data, pid, idField, pidField) {if (typeof idField == 'undefined') {idField = 'id';}if (typeof pidField == 'undefined') {pidField == 'pid';}const result = [];let temp;for (let i = 0; i < data.length; i++) {if (data[i][pidField] === pid) { // 如果元素的pid==0temp = getDeptTreeCustom(data, data[i][idField], idField, pidField);if (temp.length > 0) {data[i].children = temp;}result.push(data[i]);}}return result;
}
let all = getDeptTreeCustom(y,'0', 'uuid', 'pid')
console.log(all)

这篇关于vue数据转树状结构进阶(两级父节点)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/642046

相关文章

Vue3 的 shallowRef 和 shallowReactive:优化性能

大家对 Vue3 的 ref 和 reactive 都很熟悉,那么对 shallowRef 和 shallowReactive 是否了解呢? 在编程和数据结构中,“shallow”(浅层)通常指对数据结构的最外层进行操作,而不递归地处理其内部或嵌套的数据。这种处理方式关注的是数据结构的第一层属性或元素,而忽略更深层次的嵌套内容。 1. 浅层与深层的对比 1.1 浅层(Shallow) 定义

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

大模型研发全揭秘:客服工单数据标注的完整攻略

在人工智能(AI)领域,数据标注是模型训练过程中至关重要的一步。无论你是新手还是有经验的从业者,掌握数据标注的技术细节和常见问题的解决方案都能为你的AI项目增添不少价值。在电信运营商的客服系统中,工单数据是客户问题和解决方案的重要记录。通过对这些工单数据进行有效标注,不仅能够帮助提升客服自动化系统的智能化水平,还能优化客户服务流程,提高客户满意度。本文将详细介绍如何在电信运营商客服工单的背景下进行

基于MySQL Binlog的Elasticsearch数据同步实践

一、为什么要做 随着马蜂窝的逐渐发展,我们的业务数据越来越多,单纯使用 MySQL 已经不能满足我们的数据查询需求,例如对于商品、订单等数据的多维度检索。 使用 Elasticsearch 存储业务数据可以很好的解决我们业务中的搜索需求。而数据进行异构存储后,随之而来的就是数据同步的问题。 二、现有方法及问题 对于数据同步,我们目前的解决方案是建立数据中间表。把需要检索的业务数据,统一放到一张M

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

关于数据埋点,你需要了解这些基本知识

产品汪每天都在和数据打交道,你知道数据来自哪里吗? 移动app端内的用户行为数据大多来自埋点,了解一些埋点知识,能和数据分析师、技术侃大山,参与到前期的数据采集,更重要是让最终的埋点数据能为我所用,否则可怜巴巴等上几个月是常有的事。   埋点类型 根据埋点方式,可以区分为: 手动埋点半自动埋点全自动埋点 秉承“任何事物都有两面性”的道理:自动程度高的,能解决通用统计,便于统一化管理,但个性化定

【 html+css 绚丽Loading 】000046 三才归元阵

前言:哈喽,大家好,今天给大家分享html+css 绚丽Loading!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕 目录 📚一、效果📚二、信息💡1.简介:💡2.外观描述:💡3.使用方式:💡4.战斗方式:💡5.提升:💡6.传说: 📚三、源代码,上代码,可以直接复制使用🎥效果🗂️目录✍️

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

异构存储(冷热数据分离)

异构存储主要解决不同的数据,存储在不同类型的硬盘中,达到最佳性能的问题。 异构存储Shell操作 (1)查看当前有哪些存储策略可以用 [lytfly@hadoop102 hadoop-3.1.4]$ hdfs storagepolicies -listPolicies (2)为指定路径(数据存储目录)设置指定的存储策略 hdfs storagepolicies -setStoragePo

Hadoop集群数据均衡之磁盘间数据均衡

生产环境,由于硬盘空间不足,往往需要增加一块硬盘。刚加载的硬盘没有数据时,可以执行磁盘数据均衡命令。(Hadoop3.x新特性) plan后面带的节点的名字必须是已经存在的,并且是需要均衡的节点。 如果节点不存在,会报如下错误: 如果节点只有一个硬盘的话,不会创建均衡计划: (1)生成均衡计划 hdfs diskbalancer -plan hadoop102 (2)执行均衡计划 hd