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

element tree树形结构默认展开全部

背景:

el-tree树形结构,默认展开全部,使用属性default-expand-all【是否默认展开所有节点】;默认展开一级,设置default-expanded-keys【默认展开的节点的 key 的数组】属性值为数组。

因为我这里的数据第一级是四川【省下面的所有市级】,所以只需要把四川的node-key="pid"的值找出,即四川为 51,赋值给default-expanded-keys,那么default-expanded-keys=[51]就实现的下面右图的效果。

效果展示:

左图:默认展开全部,右图:展开一级

核心代码:

//:default-expand-all = "true"默认展开全部
//:default-expanded-keys="[51]"默认展开四川<el-treestyle="max-width: 600px":data="state.ferryPortList":props="state.defaultProps"@node-click="handleNodeClick"node-key="pid":default-expand-all = "true"/>

官网链接:点击跳转

写到这儿变完成了。。。以下是el-tree组件的一些属性说明:

一、el-tree组件的属性

 el-tree的属性及其含义:

:data="state.ferryPortList"

展示数据

 :props="state.defaultProps"

配置选项

defaultProps: {label: "name",value: "pid",},

node-key="pid" 

设置node-key属性,每个树节点用来作为唯一标识的属性,整棵树应该是唯一的。

例如:node-key="id" 或 node-key="pid" 

:default-expand-all = "true"

是否默认展开所有节点

:default-expanded-keys="state.expandedKeys" 

默认展开的节点的 key 的数组

 示例数据:

接口数据结构,一维数组:

//示例数据结构,对象数组,一维数组[{pid: 0,parentId: -1,name: "全部",type: -1,count: null,visible: null,geom: null,ferryPortAreaVos: [],portShipVoList: null,},{pid: 51,parentId: 0,name: "四川 (24)",type: 0,count: 24,visible: null,geom: "0101000000F7CC920035045A40BE839F3880923E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 5113,parentId: 51,name: "南充 (24)",type: 1,count: 24,visible: null,geom: "01010000000DE02D90A0845A40CFF753E3A5CB3E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511302,parentId: 5113,name: "顺庆",type: 2,count: 0,visible: null,geom: "01010000000DE02D90A0845A40CFF753E3A5CB3E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511303,parentId: 5113,name: "高坪",type: 2,count: 0,visible: null,geom: "0101000000B37BF2B050875A40F4FDD478E9C63E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511304,parentId: 5113,name: "嘉陵",type: 2,count: 0,visible: null,geom: "0101000000C898BB9690835A40E17A14AE47C13E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511321,parentId: 5113,name: "南部 (17)",type: 2,count: 17,visible: null,geom: "0101000000575BB1BFEC825A40643BDF4F8D573F40",ferryPortAreaVos: [{name: "仙家坟渡口",pid: 80,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "太霞三岔河码头",pid: 78,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "太霞乡西河码头",pid: 76,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "富利镇宋家咀渡口(上)",pid: 70,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "富利镇宋家咀渡口(下)",pid: 28,areaId: 511321,type: 100,ferryShipVoList: [{pid: 17,cname: null,name: "西充渡船",mmsi: null,carryPassengersNum: null,status: null,areaId: 511321,type: 101,speakerDto: null,},{pid: 29,cname: null,name: "富利渡船",mmsi: null,carryPassengersNum: null,status: null,areaId: 511321,type: 101,speakerDto: null,},],},{name: "李家岩渡口",pid: 79,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "杨家洞渡口",pid: 74,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "楠木镇泸溪场渡口(上)",pid: 67,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "楠木镇泸溪场渡口(下)",pid: 71,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "江石岭渡口",pid: 85,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "河口上渡口",pid: 83,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "观音岩渡口(上)",pid: 69,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "观音岩渡口(下)",pid: 66,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "金鸡河渡口",pid: 81,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "陈家口渡口",pid: 86,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "鲁家坝渡口",pid: 82,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "麻溪寺渡口",pid: 84,areaId: 511321,type: 100,ferryShipVoList: [],},],portShipVoList: null,},{pid: 511322,parentId: 5113,name: "营山",type: 2,count: 0,visible: null,geom: "01010000002A3A92CB7FA45A403333333333133F40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511323,parentId: 5113,name: "蓬安 (5)",type: 2,count: 5,visible: null,geom: "010100000048E17A14AE9B5A40BEC1172653053F40",ferryPortAreaVos: [{name: "八字老渡口上",pid: 64,areaId: 511323,type: 100,ferryShipVoList: [{pid: 51,cname: null,name: "川蓬安渡0012",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},{pid: 52,cname: null,name: "川蓬安渡0011",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},{name: "八字老渡口下",pid: 63,areaId: 511323,type: 100,ferryShipVoList: [{pid: 51,cname: null,name: "川蓬安渡0012",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},{pid: 52,cname: null,name: "川蓬安渡0011",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},{name: "八字老渡口下(对岸)",pid: 68,areaId: 511323,type: 100,ferryShipVoList: [{pid: 51,cname: null,name: "川蓬安渡0012",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},{name: "史家坝渡口",pid: 62,areaId: 511323,type: 100,ferryShipVoList: [],},{name: "金坡梁村渡口",pid: 61,areaId: 511323,type: 100,ferryShipVoList: [{pid: 50,cname: null,name: "川蓬安客0050",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},],portShipVoList: null,},{pid: 511324,parentId: 5113,name: "仪陇",type: 2,count: 0,visible: null,geom: "01010000000C022B8716995A404A0C022B87863F40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511325,parentId: 5113,name: "西充",type: 2,count: 0,visible: null,geom: "01010000003108AC1C5A785A408FC2F5285CFF3E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511381,parentId: 5113,name: "阆中 (2)",type: 2,count: 2,visible: null,geom: "010100000051DA1B7C617E5A400000000000903F40",ferryPortAreaVos: [{name: "犀牛渡口",pid: 59,areaId: 511381,type: 100,ferryShipVoList: [{pid: 49,cname: null,name: "川阆中渡0020",mmsi: null,carryPassengersNum: null,status: null,areaId: 511381,type: 101,speakerDto: null,},],},{name: "鞍子湾渡口",pid: 58,areaId: 511381,type: 100,ferryShipVoList: [{pid: 49,cname: null,name: "川阆中渡0020",mmsi: null,carryPassengersNum: null,status: null,areaId: 511381,type: 101,speakerDto: null,},],},],portShipVoList: null,},];

数据处理后,多维数组:

树形结构绑定的:data是经过处理之后的值,例如以下:

[{"pid": 51,"parentId": 0,"name": "四川 (24)","type": 0,"count": 24,"visible": null,"geom": "0101000000F7CC920035045A40BE839F3880923E40","ferryPortAreaVos": [],"portShipVoList": null,"children": [{"pid": 5113,"parentId": 51,"name": "南充 (24)","type": 1,"count": 24,"visible": null,"geom": "01010000000DE02D90A0845A40CFF753E3A5CB3E40","ferryPortAreaVos": [],"portShipVoList": null,"children": [{"pid": 511302,"parentId": 5113,"name": "顺庆","type": 2,"count": 0,"visible": null,"geom": "01010000000DE02D90A0845A40CFF753E3A5CB3E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511303,"parentId": 5113,"name": "高坪","type": 2,"count": 0,"visible": null,"geom": "0101000000B37BF2B050875A40F4FDD478E9C63E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511304,"parentId": 5113,"name": "嘉陵","type": 2,"count": 0,"visible": null,"geom": "0101000000C898BB9690835A40E17A14AE47C13E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511321,"parentId": 5113,"name": "南部 (17)","type": 2,"count": 17,"visible": null,"geom": "0101000000575BB1BFEC825A40643BDF4F8D573F40","ferryPortAreaVos": [{"name": "仙家坟渡口","pid": 80,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞三岔河码头","pid": 78,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞乡西河码头","pid": 76,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(上)","pid": 70,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(下)","pid": 28,"areaId": 511321,"type": 100,"ferryShipVoList": [{"pid": 17,"cname": null,"name": "西充渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null},{"pid": 29,"cname": null,"name": "富利渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null}]},{"name": "李家岩渡口","pid": 79,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "杨家洞渡口","pid": 74,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(上)","pid": 67,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(下)","pid": 71,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "江石岭渡口","pid": 85,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "河口上渡口","pid": 83,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(上)","pid": 69,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(下)","pid": 66,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "金鸡河渡口","pid": 81,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "陈家口渡口","pid": 86,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "鲁家坝渡口","pid": 82,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "麻溪寺渡口","pid": 84,"areaId": 511321,"type": 100,"ferryShipVoList": []}],"portShipVoList": null,"children": [{"name": "仙家坟渡口","pid": 80,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞三岔河码头","pid": 78,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞乡西河码头","pid": 76,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(上)","pid": 70,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(下)","pid": 28,"areaId": 511321,"type": 100,"ferryShipVoList": [{"pid": 17,"cname": null,"name": "西充渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null},{"pid": 29,"cname": null,"name": "富利渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null}]},{"name": "李家岩渡口","pid": 79,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "杨家洞渡口","pid": 74,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(上)","pid": 67,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(下)","pid": 71,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "江石岭渡口","pid": 85,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "河口上渡口","pid": 83,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(上)","pid": 69,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(下)","pid": 66,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "金鸡河渡口","pid": 81,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "陈家口渡口","pid": 86,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "鲁家坝渡口","pid": 82,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "麻溪寺渡口","pid": 84,"areaId": 511321,"type": 100,"ferryShipVoList": []}]},{"pid": 511322,"parentId": 5113,"name": "营山","type": 2,"count": 0,"visible": null,"geom": "01010000002A3A92CB7FA45A403333333333133F40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511323,"parentId": 5113,"name": "蓬安 (5)","type": 2,"count": 5,"visible": null,"geom": "010100000048E17A14AE9B5A40BEC1172653053F40","ferryPortAreaVos": [{"name": "八字老渡口上","pid": 64,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下","pid": 63,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下(对岸)","pid": 68,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "史家坝渡口","pid": 62,"areaId": 511323,"type": 100,"ferryShipVoList": []},{"name": "金坡梁村渡口","pid": 61,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 50,"cname": null,"name": "川蓬安客0050","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]}],"portShipVoList": null,"children": [{"name": "八字老渡口上","pid": 64,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下","pid": 63,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下(对岸)","pid": 68,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "史家坝渡口","pid": 62,"areaId": 511323,"type": 100,"ferryShipVoList": []},{"name": "金坡梁村渡口","pid": 61,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 50,"cname": null,"name": "川蓬安客0050","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]}]},{"pid": 511324,"parentId": 5113,"name": "仪陇","type": 2,"count": 0,"visible": null,"geom": "01010000000C022B8716995A404A0C022B87863F40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511325,"parentId": 5113,"name": "西充","type": 2,"count": 0,"visible": null,"geom": "01010000003108AC1C5A785A408FC2F5285CFF3E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511381,"parentId": 5113,"name": "阆中 (2)","type": 2,"count": 2,"visible": null,"geom": "010100000051DA1B7C617E5A400000000000903F40","ferryPortAreaVos": [{"name": "犀牛渡口","pid": 59,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]},{"name": "鞍子湾渡口","pid": 58,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]}],"portShipVoList": null,"children": [{"name": "犀牛渡口","pid": 59,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]},{"name": "鞍子湾渡口","pid": 58,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]}]}]}]}
]

多维数组,绑定给树结构。。。 

封装方法:

对接口的数据进行处理,把平面数组转树形结构:

/*** 平面数组转树形结构* @param data 平面数组* @param pid 树节点元素的id* @param idKey id字段* @param pidKey pid字段* @param sortKey 可选,排序字段* @returns {*[]}*/
export function arrayToTreeRec({data, pid = 0, idKey = 'id', pidKey = 'parent_id', sortKey = ''}) {const map = {};let tree = [];const d = JSON.parse(JSON.stringify(data))for (const item of d) {map[item[idKey]] = {...item, children: item.ferryPortAreaVos && item.ferryPortAreaVos.length ? item.ferryPortAreaVos : []};}for (const item of Object.values(map)) {if (item[pidKey] === pid) {tree.push(item);} else {map[item[pidKey]].children.push(item);if (sortKey) {map[item[pidKey]].children = map[item[pidKey]].children.sort((a, b) => a[sortKey] - b[sortKey])}}}if (sortKey) tree = tree.sort((a, b) => a[sortKey] - b[sortKey])return tree
}

相关文章:

element tree树形结构默认展开全部

背景&#xff1a; el-tree树形结构&#xff0c;默认展开全部&#xff0c;使用属性default-expand-all【是否默认展开所有节点】&#xff1b;默认展开一级&#xff0c;设置default-expanded-keys【默认展开的节点的 key 的数组】属性值为数组。 因为我这里的数据第一级是四川【省…...

统计登录系统10秒内连续登录失败超过3次的用户

为防止暴力破解用户账号的行为&#xff0c;在输入账号和密码时一般都会限制用户尝试密码输出错误的次数&#xff0c;如果用户多次输错密码后&#xff0c;将在一段时间内锁定账号&#xff0c;常见的有银行类APP、个税App等应用&#xff0c;如下是用户账号密码输入错误的提示图&a…...

音视频软件工程师面试题

一、基础知识 编解码相关 H.264 和 H.265(HEVC)的主要区别是什么?视频编解码的基本流程是什么?关键技术有哪些?音频编解码(如 AAC、MP3、Opus)的区别和应用场景?什么是 B 帧、P 帧、I 帧?它们的作用是什么? 流媒体协议RTMP、HTTP-FLV、HLS、WebRTC 的区别和应用场景…...

架构师面试(十四):注册中心设计

问题 大家或多或少都接触过【注册中心】&#xff0c;对注册中心的基本功能&#xff0c;如&#xff1a;服务注册、服务发现、健康检查和变更通知 &#xff0c;肯定是耳熟能详的&#xff1b;那么大家对注册中心的架构设计是否了解呢&#xff1f; 如果让你负责设计一个分布式的注…...

ctf-web: php原生类利用 -- GHCTF Popppppp

源代码 <?php error_reporting(0); class CherryBlossom { public $fruit1; public $fruit2; public function __construct($a) {$this->fruit1 $a; } function __destruct() { echo $this->fruit1; } public function __toString() { $newFunc …...

「Unity3D」UGUI将元素固定在,距离屏幕边缘的某个比例,以及保持元素自身比例

在不同分辨率的屏幕下&#xff0c;UI元素按照自身像素大小&#xff0c;会发生位置与比例的变化&#xff0c;本文仅利用锚点&#xff08;Anchors&#xff09;使用&#xff0c;来实现UI元素&#xff0c;固定在某个比例距离的屏幕边缘。 首先&#xff0c;将元素的锚点设置为中心&…...

nextjs15简要介绍以及配置eslint和prettier

目录 一、Next.js 何时使用服务器端渲染&#xff08;SSR&#xff09;&#xff1f;何时使用静态生成&#xff08;SSG&#xff09;&#xff1f; 1、服务器端渲染&#xff08;SSR - getServerSideProps&#xff09; 2、 静态生成&#xff08;SSG - getStaticProps&#xff09; …...

存储过程和自定义函数在银行信贷业务中的应用(oracle)

数据校验和清洗 例如&#xff0c;检查客户的年龄是否在合理范围内&#xff0c;贷款金额是否符合规定的上下限等。 对于不符合规则的数据&#xff0c;可以进行清洗和修正。比如&#xff0c;将空值替换为默认值&#xff0c;或者对错误的数据进行纠正。 CREATE OR REPLACE PROC…...

基于Ollama平台部署的Qwen大模型实现聊天机器人

文章目录 基于Ollama平台部署的Qwen大模型实现聊天机器人1 概述2 技术栈2.1 开发技术2.2 环境 3 技术架构4 实现步骤4.1 环境搭建4.1.1 WSL配置及Ubuntu安装4.1.2 Ollama安装及模型部署 4.2 模块安装4.2.1 安装Streamlit 1.42.24.2.2 安装requests 2.32.34.2.3 安装ollama 0.4.…...

在 JDK 1.8 的 ConcurrentHashMap 中,为什么存在两种插入方式?

在 JDK 1.8 的 ConcurrentHashMap 中&#xff0c;之所以对“容器为空”和“计算位置为空”采取不同的处理方式&#xff0c;主要是因为 并发场景下的性能优化和并发安全保证。我们可以分开来看这两种情况&#xff1a; 1. 容器为空时&#xff0c;使用 volatile CAS 初始化 原因…...

如何让powershell的界面变成全屏显示?

刚打开powershell&#xff0c;原来的样子&#xff1a; 全屏&#xff1a;可以按一下键盘上的alt enter 键&#xff0c;效果&#xff1a;...

语音识别踩坑记录

本来想在原来的语音识别的基础上增加本地扩展本地词典&#xff0c; 采用的语音识别是Vosk识别器&#xff0c;模型是 vosk-model-small-cn-0.22 // 初始化Vosk识别器 if (recognizer null) {using (Model model new Model(modelPath)){string grammar "{""…...

图片查看器:用PyQt5实现本地图片预览工具

通过python代码&#xff0c;基于PyQt5实现本地图片预览查看工具。 我们对窗口进行了圆角设计&#xff0c;图片的翻页按钮半透明处理&#xff0c;当鼠标移动至按钮上的动画效果&#xff0c;当选择某一张图片&#xff0c;进行左右翻页则轮播同目录所有支持的图片格式。 import …...

Deepin通过二进制方式升级部署高版本 Docker

一、背景&#xff1a; 在Deepin系统中通过二进制方式升级部署高版本 Docker&#xff0c;下面将详细介绍二进制方式升级部署高版本 Docker 的具体步骤。 二、操作步骤 1.根据需求下载二进制文件&#xff0c;下载地址如下&#xff1a; https://mirrors.tuna.tsinghua.e…...

车架号VIN查询 API 接口用JAVA如何调用?

以下是车架号VIN查询 API 接口用JAVA如何调用的示例代码&#xff1a; package com.shuxun.data.impl.demo;import com.shuxun.common.core.util.HttpUtil; import org.apache.commons.codec.digest.DigestUtils;import java.util.HashMap; import java.util.Map;public class …...

Vulnhub 靶机 VulnOSv2 write up opendocman cms 32075 sql注入 账号密码 ssh连接 37292.c 脏牛提权

Vulnhub 靶机 VulnOSv2 write up opendocman cms 32075 sql注入 账号密码 ssh连接 37292.c 脏牛提权 一、信息收集 1、首先拿到靶场先扫一下ip arp-scan -l 3、 2、指纹扫描 nmap -sS -sV 192.168.66.178nmap -p- -sV -A 192.168.66.253 PORT STATE SERVICE VERSION 22…...

爬虫的精准识别:基于 User-Agent 的正则实现

&#x1f9d1; 博主简介&#xff1a;CSDN博客专家&#xff0c;历代文学网&#xff08;PC端可以访问&#xff1a;https://literature.sinhy.com/#/?__c1000&#xff0c;移动端可微信小程序搜索“历代文学”&#xff09;总架构师&#xff0c;15年工作经验&#xff0c;精通Java编…...

Python数据分析之数据可视化

Python 数据分析重点知识点 本系列不同其他的知识点讲解&#xff0c;力求通过例子让新同学学习用法&#xff0c;帮助老同学快速回忆知识点 可视化系列&#xff1a; Python基础数据分析工具数据处理与分析数据可视化机器学习基础 四、数据可视化 图表类型与选择 根据数据特…...

【免费】2004-2020年各省货运量数据

2004-2020年各省货运量数据 1、时间&#xff1a;2004-2020年 2、来源&#xff1a;国家统计局、统计年鉴 3、指标&#xff1a;行政区划代码、地区、年份、货运量(万吨) 4、范围&#xff1a;31省 5、指标解释&#xff1a;货运量指在一定时期内&#xff0c;各种运输工具实际运…...

【CXX】6.6 UniquePtr<T> — std::unique_ptr<T>

std::unique_ptr 的 Rust 绑定称为 UniquePtr。有关 Rust API 的文档&#xff0c;请参见链接。 限制&#xff1a; 目前仅支持 std::unique_ptr<T, std::default_delete>。未来可能会支持自定义删除器。 UniquePtr 不支持 T 为不透明的 Rust 类型。对于在语言边界传递不…...

Cursor实现用excel数据填充word模版的方法

cursor主页&#xff1a;https://www.cursor.com/ 任务目标&#xff1a;把excel格式的数据里的单元格&#xff0c;按照某一个固定模版填充到word中 文章目录 注意事项逐步生成程序1. 确定格式2. 调试程序 注意事项 直接给一个excel文件和最终呈现的word文件的示例&#xff0c;…...

PHP和Node.js哪个更爽?

先说结论&#xff0c;rust完胜。 php&#xff1a;laravel&#xff0c;swoole&#xff0c;webman&#xff0c;最开始在苏宁的时候写了几年php&#xff0c;当时觉得php真的是世界上最好的语言&#xff0c;因为当初活在舒适圈里&#xff0c;不愿意跳出来&#xff0c;就好比当初活在…...

循环冗余码校验CRC码 算法步骤+详细实例计算

通信过程&#xff1a;&#xff08;白话解释&#xff09; 我们将原始待发送的消息称为 M M M&#xff0c;依据发送接收消息双方约定的生成多项式 G ( x ) G(x) G(x)&#xff08;意思就是 G &#xff08; x ) G&#xff08;x) G&#xff08;x) 是已知的&#xff09;&#xff0…...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?

在建筑行业&#xff0c;项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升&#xff0c;传统的管理模式已经难以满足现代工程的需求。过去&#xff0c;许多企业依赖手工记录、口头沟通和分散的信息管理&#xff0c;导致效率低下、成本失控、风险频发。例如&#…...

vue3+vite项目中使用.env文件环境变量方法

vue3vite项目中使用.env文件环境变量方法 .env文件作用命名规则常用的配置项示例使用方法注意事项在vite.config.js文件中读取环境变量方法 .env文件作用 .env 文件用于定义环境变量&#xff0c;这些变量可以在项目中通过 import.meta.env 进行访问。Vite 会自动加载这些环境变…...

学习STC51单片机32(芯片为STC89C52RCRC)OLED显示屏2

每日一言 今天的每一份坚持&#xff0c;都是在为未来积攒底气。 案例&#xff1a;OLED显示一个A 这边观察到一个点&#xff0c;怎么雪花了就是都是乱七八糟的占满了屏幕。。 解释 &#xff1a; 如果代码里信号切换太快&#xff08;比如 SDA 刚变&#xff0c;SCL 立刻变&#…...

Web 架构之 CDN 加速原理与落地实践

文章目录 一、思维导图二、正文内容&#xff08;一&#xff09;CDN 基础概念1. 定义2. 组成部分 &#xff08;二&#xff09;CDN 加速原理1. 请求路由2. 内容缓存3. 内容更新 &#xff08;三&#xff09;CDN 落地实践1. 选择 CDN 服务商2. 配置 CDN3. 集成到 Web 架构 &#xf…...

C++.OpenGL (14/64)多光源(Multiple Lights)

多光源(Multiple Lights) 多光源渲染技术概览 #mermaid-svg-3L5e5gGn76TNh7Lq {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-3L5e5gGn76TNh7Lq .error-icon{fill:#552222;}#mermaid-svg-3L5e5gGn76TNh7Lq .erro…...

【JVM面试篇】高频八股汇总——类加载和类加载器

目录 1. 讲一下类加载过程&#xff1f; 2. Java创建对象的过程&#xff1f; 3. 对象的生命周期&#xff1f; 4. 类加载器有哪些&#xff1f; 5. 双亲委派模型的作用&#xff08;好处&#xff09;&#xff1f; 6. 讲一下类的加载和双亲委派原则&#xff1f; 7. 双亲委派模…...

【JVM】Java虚拟机(二)——垃圾回收

目录 一、如何判断对象可以回收 &#xff08;一&#xff09;引用计数法 &#xff08;二&#xff09;可达性分析算法 二、垃圾回收算法 &#xff08;一&#xff09;标记清除 &#xff08;二&#xff09;标记整理 &#xff08;三&#xff09;复制 &#xff08;四&#xff…...