vue3实现自定义select下拉框内容之城市区域篇
分享-2023年资深前端进阶:前端登顶之巅-最全面的前端知识点梳理总结
*分享一个使用比较久的🪜
需求分析:
1、实现一个区域下拉选项与现有ui组件库不同,支持多选、单选需求
2、支持选中区域后-全选中当前区域下的所有城市信息
3、只能选中当前一个区域的内的城市其余城市禁用
扩展思路:
1、封装公共组件或者封装在组件库内
2、出入参相关api透明好理解
3、支持单选或者多选,支持只选择当前区域下的城市或者全面区域下的城市
4、在原有的element plus下进行扩展延伸满足需求
5、缺陷:未做maxLength-标签最大展示的api;这个按需自己修改一下就行
1、第一种模式:显示区域信息

2、第二种模式:只展示城市内容

1、相关开发代码篇
创建文件:custom-select.vue文件;复制copy当下代码;
使用方式:
1、外部入参例如城市:dataSource=[{ label: 华北,value: '华东', children: [{ label: '山东',value: 'shandong'}]],树形结构
2、标签引用:<custom-select :disabled="true" :multilevel="true" height="32" v-model="checkGroup" :dataSource="cityList"></custom-select>
3、相关api说明文档在文章底部
<template><divtabindex="1"ref="customSelectRef"@click="handleClickDiv"@mouseenter="handelMouseEnter"@mouseleave="handleMouseLeave":style="{ width: modelLabel && modelValue?.length ? '166px' : '100px', height: (height + 'px') || '25px' }":class="['custom-select_contaniner-i', isShowDropdown && 'custom-select_background']"><div><span v-if="modelLabel" class="custom-tag"><span>{{ modelLabel }}</span><iclass="custom_tag_delete"@mouseenter="handelIconMouseEnter"@mouseleave="handleIconMouseLeave"@click.stop="handleDeleteIcon"><svgv-if="!ishShowIconDeleteText"t="1678090923023"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="6709"width="11"height="11"><pathd="M263.802377 224.219482a7.964444 7.964444 0 0 1 11.263425 0l236.934198 236.934198 236.934198-236.934198a7.964444 7.964444 0 0 1 11.263425 0l39.582895 39.582895a7.964444 7.964444 0 0 1 0 11.263425l-236.934198 236.934198 236.934198 236.934198a7.964444 7.964444 0 0 1 0 11.263425l-39.582895 39.582895a7.964444 7.964444 0 0 1-11.263425 0l-236.934198-236.934198-236.934198 236.934198a7.964444 7.964444 0 0 1-11.263425 0l-39.582895-39.582895a7.964444 7.964444 0 0 1 0-11.263425l236.934198-236.934198-236.934198-236.934198a7.964444 7.964444 0 0 1 0-11.263425l39.582895-39.582895z"fill="#8a8a8a"p-id="6710"/></svg><svgv-elset="1678091410677"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="6936"width="22"height="22"><pathd="M479.072 512l-98.72-98.72c-9.152-9.152-9.088-23.84 0-32.928 9.152-9.152 23.84-9.088 32.928 0l98.72 98.72 98.72-98.72c9.152-9.152 23.84-9.088 32.928 0 9.152 9.152 9.088 23.84 0 32.928l-98.72 98.72 98.72 98.72c9.152 9.152 9.088 23.84 0 32.928-9.152 9.152-23.84 9.088-32.928 0l-98.72-98.72-98.72 98.72c-9.152 9.152-23.84 9.088-32.928 0-9.152-9.152-9.088-23.84 0-32.928l98.72-98.72zM512 837.824c179.936 0 325.824-145.888 325.824-325.824s-145.888-325.824-325.824-325.824c-179.936 0-325.824 145.888-325.824 325.824s145.888 325.824 325.824 325.824z"fill="#B7B8B9"p-id="6937"/></svg></i></span><span v-if="modelLabel && modelValue?.length > 1" class="custom-tag">+ {{ modelValue.length - 1 }}</span><span v-if="!modelLabel" class="cus_placeholder">{{ placeholder }}</span></div><i class="arrow-top-icon" v-if="!isShowIconRemove || !modelLabel" :class="[!isShowDropdown && 'arrow-top-icon-active']"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><pathfill="currentColor"d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"/></svg></i><i class="remove-icon" v-if="isShowIconRemove && modelLabel" @click.stop="handleRemove"><svgt="1678084213981"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="4480"width="11"height="11"><pathd="M512 32c265.097 0 480 214.903 480 480S777.097 992 512 992 32 777.097 32 512 246.903 32 512 32z m0 64C282.25 96 96 282.25 96 512s186.25 416 416 416 416-186.25 416-416S741.75 96 512 96z m169.706 246.294c12.496 12.497 12.496 32.758 0 45.255L557.256 512l124.45 124.452c12.496 12.497 12.496 32.758 0 45.255-12.497 12.496-32.758 12.496-45.255 0L512 557.254 387.549 681.706c-12.497 12.496-32.758 12.496-45.255 0-12.496-12.497-12.496-32.758 0-45.255l124.452-124.452-124.452-124.45c-12.496-12.497-12.496-32.758 0-45.255 12.497-12.496 32.758-12.496 45.255 0l124.452 124.45 124.45-124.45c12.497-12.496 32.758-12.496 45.255 0z"fill="#8a8a8a"p-id="4481"/></svg></i></div><transition><divv-if="isShowDropdown"ref="cusSelectDropdown"class="cus_select_background":style="{ minWidth: popperOffestWidth + 'px', zIndex: 99999 }"><div v-if="multilevel" style="padding: 5px 20px;"><div :key="key" v-for="(opt, key) in cusDataListChecked" class="multilevel_box"><el-checkboxstyle="width: 60px;"v-model="opt.checkAll"@change="handleCheckAllChange($event, opt)":indeterminate="opt.isIndeterminate":disabled="disabled && checkList.length ? !opt.checkList.length : false">{{ opt.label }}</el-checkbox><el-checkbox-group v-model="opt.checkList"v-if="opt.children"@change="handleCheckedCitiesChange($event, opt)"style="display: inline-block; padding-left: 20px" ><el-checkbox :label="item.value" style="width: 60px":key="index + Math.random()" v-for="(item, index) in opt.children" :disabled="disabled && checkList.length ? !opt.checkList.length : false">{{ item.label }}</el-checkbox></el-checkbox-group></div></div><div class="cus_select_contaniner" v-else><div class="cus_select_left">中国</div><div class="cus_select_right"><el-checkbox-group v-model="checkList" @change="handelCheckGroup"style="display: inline-block; padding-left: 20px" ><el-checkbox :key="index" :label="item.value" style="width: 60px"v-for="(item, index) in dataSource" >{{ item.label }}</el-checkbox></el-checkbox-group></div></div><span class="el-popper__arrow" data-popper-arrow="" style="position: absolute; left: 140px;"></span></div></transition>
</template>
<script setup lang="ts">
import { createPopper } from '@popperjs/core'
import { ref, onMounted, nextTick, watch, onUnmounted, toRaw, onBeforeMount, computed } from 'vue'const props = withDefaults(defineProps<{height?: string | numberdataSource: anymodelValue?: anyplaceholder?: stringmultilevel?: booleandisabled?: boolean}>(),{height: 25,disabled: false,multilevel: false,dataSource: [],modelValue: [],placeholder: '请选择'}
)const emit = defineEmits(['update:modelValue'])const customSelectRef = ref()const cusSelectDropdown = ref()const cusDataListChecked = ref<any[]>([])const checkList = ref<string[]>([])const popperOffestWidth = ref<number>(0)const isShowDropdown = ref<boolean>(false)const modelLabel = ref<string>('')const isShowIconRemove = ref<boolean>(false)const ishShowIconDeleteText = ref<boolean>(false)const handleClickDiv = () => {isShowDropdown.value = !isShowDropdown.value
}const handelCheckGroup = (value) => {const obj = props.dataSource.filter((item) => item.value === value[0])[0]modelLabel.value = obj?.labelemit('update:modelValue', value)
}const handelMouseEnter = () => {isShowIconRemove.value = true
}const handleMouseLeave = () => {isShowIconRemove.value = false
}const handleRemove = () => {modelLabel.value = ''checkList.value = []if (isShowDropdown.value) {isShowDropdown.value = false}if (props.multilevel) {cusDataListChecked.value = addCheckProperties(props.dataSource)}emit('update:modelValue', [])
}const handleDeleteIcon = () => {isShowDropdown.value = falsecheckList.value.splice(0, 1)if (props.multilevel) return cusDataListChecked.value = findTreeChecked(cusDataListChecked.value)const info = toRaw(checkList.value)[0]const obj = props.dataSource.filter((item) => item.value === info)[0]modelLabel.value = obj?.label || ''
}const handelIconMouseEnter = () => {ishShowIconDeleteText.value = true
}const handleIconMouseLeave = () => {ishShowIconDeleteText.value = false
}// 点击某个DOM元素之外的方法
const handlerDocClick = (event) => {const isSelf = customSelectRef.value?.contains(event.target) || cusSelectDropdown.value?.contains(event.target)if (!isSelf) {isShowDropdown.value = false}
}/*** 展示区域省份的逻辑* */
const handleCheckAllChange = (bool: any, option) => {const allCity = option.children ? option.children.map(item => item.value) : [option.value]bool ? option.checkList = allCity : option.checkList = []option.isIndeterminate = falsecheckList.value = option.checkListconst newLabelArr = option.children ? option.children.filter(item => checkList.value.includes(item.value)) : checkList.value?.length ? [{ label: '默认' }] : []modelLabel.value = newLabelArr?.[0]?.label || ''emit('update:modelValue', checkList.value)
}const handleCheckedCitiesChange = (value: any[], option) => {const checkedCount = value.lengthconst allCity = option.children ? option.children.map(item => item.value) : [option.value]option.checkAll = checkedCount === allCity.lengthoption.isIndeterminate = checkedCount > 0 && checkedCount < allCity.lengthcheckList.value = option.checkListconst newLabelArr = option.children ? option.children.filter(item => checkList.value.includes(item.value)) : checkList.value?.length ? [{ label: '默认' }] : []modelLabel.value = newLabelArr?.[0]?.label || ''emit('update:modelValue', checkList.value)
}const addCheckProperties = (treeData) => {let result = []result = JSON.parse(JSON.stringify(treeData))result.forEach(node => {const child = node.children;node.checkAll = false;node.isIndeterminate = false;node.checkList = [];if (child && child.length > 0) {addCheckProperties(child);}});return result
}const findTreeChecked = (treeData) => {let newLabelconst val = toRaw(checkList.value)const defaultBool = val.some(item => item.includes('default'))treeData.forEach(node => {if (node.children?.length) {const child = node.children;const bool = child.some(opt => val.includes(opt.value))!newLabel ? newLabel = child.filter(item => val.includes(item.value))[0] : void nullif (bool) {node.checkAll = val.length === child?.length;node.isIndeterminate = val.length > 0 && val.length < child?.length;node.checkList = val;} else {node.isIndeterminate = false}}})treeData[0].isIndeterminate = false;treeData[0].checkAll = defaultBool ? true : false;treeData[0].checkList = defaultBool ? ['default'] : [];modelLabel.value = defaultBool ? '默认' : newLabel?.label || ''return treeData
}watch([customSelectRef, cusSelectDropdown],() => {if (customSelectRef.value && cusSelectDropdown.value) {createPopper(customSelectRef.value, cusSelectDropdown.value, {placement: 'bottom',modifiers: [{name: 'offset',options: {offset: [80, 8]}}]})}},{deep: true,immediate: true}
)watch(props.modelValue,(newval) => {if (!newval || !newval.length) returncheckList.value = props.modelValueif (props.multilevel) returnconst obj = props.dataSource.filter((item) => item.value === newval[0])[0]modelLabel.value = obj?.label},{deep: true,immediate: true}
)onBeforeMount(() => {if (props.multilevel) {cusDataListChecked.value = addCheckProperties(props.dataSource)}
})onMounted(async () => {await nextTick()popperOffestWidth.value = customSelectRef.value.offsetWidthdocument.addEventListener('click', handlerDocClick, true)if (props.multilevel && props.modelValue.length) { cusDataListChecked.value = findTreeChecked(cusDataListChecked.value)}
})onUnmounted(() => {document.removeEventListener('click', handlerDocClick, true)
})
</script><script lang="ts">
export default { name: 'CustomSelect' }
</script><style lang="scss" scoped>
.v-enter-active,
.v-leave-active {transition: opacity 0.5s ease;
}.v-enter-from,
.v-leave-to {opacity: 0;
}.custom-select_contaniner-i {width: 100%;height: 25px;padding: 7px 9px;padding-left: 5px;border-radius: 4px;line-height: 1;cursor: pointer;position: relative;user-select: none;word-wrap: break-word;word-break: break-all;font-size: 13px;flex-grow: 1;display: inline-flex;align-items: center;box-sizing: border-box;justify-content: space-between;color: var(--el-input-text-color, var(--el-text-color-regular));background-color: var(--el-input-bg-color, var(--el-fill-color-blank));box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
}.custom-tag {color: var(--el-color-info);display: inline-flex;justify-content: center;align-items: center;height: 18px;padding: 0 9px;line-height: 1;border-radius: 4px;white-space: nowrap;font-size: 12px;background-color: var(--el-fill-color);
}.custom_tag_delete {width: 18px;margin-left: 5px;font-size: 0px;border-radius: 50%;display: flex;justify-content: center;align-items: center;cursor: pointer;color: var(--el-color-info);
}.custom-tag:first-child {margin-right: 6px;padding-right: 4px;
}.arrow-top-icon {width: 14px;transform: rotateX(-180deg);color: var(--el-text-color-placeholder);
}.remove-icon {margin-top: 2px;color: var(--el-text-color-placeholder);
}.arrow-top-icon-active {transform: rotateX(0deg);
}.custom-select:hover {box-shadow: 0 0 0 1px var(--el-border-color-hover) inset;
}.custom-select:focus {outline: none;box-shadow: 0 0 0 1px var(--el-color-primary) inset;
}.custom-select_background {box-shadow: 0 0 0 1px var(--el-color-primary) inset;
}::-webkit-scrollbar {width: 4px;height: 4px;background-color: transparent;
}/*滚动条的轨道*/
::-webkit-scrollbar-track {background-color: transparent;
}/*滚动条的滑块按钮*/
::-webkit-scrollbar-thumb {border-radius: 8px;background-color: rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 2px rgba(#000000, 0.04);
}/*滚动条的上下两端的按钮*/
::-webkit-scrollbar-button {height: 0;background-color: transparent;
}.cus_select_contaniner {padding: 5px 10px;display: flex;
}.cus_select_left {width: 60px;margin-top: 5px;
}.cus_select_right {flex: 1;width: 480px;
}.cus_select_background {min-height: 200px;box-sizing: border-box;border-radius: 4px;font-size: var(--el-font-size-base);color: var(--el-text-color-regular);background: var(--el-bg-color-overlay);border: 1px solid var(--el-border-color-light);.multilevel_box {display: flex; padding: 5px; border-bottom: 1px solid #e4e7ed;}.multilevel_box:last-child {border-bottom: none;}
}.cus_placeholder {color: var(--el-text-color-placeholder);
}.el-popper__arrow {top: -5px;
}.el-popper__arrow {position: absolute;width: 10px;height: 10px;z-index: -1;
}.el-popper__arrow::before {border: 1px solid var(--el-border-color-light);background: var(--el-bg-color-overlay);right: 0;border-bottom-color: transparent!important;border-right-color: transparent!important;
}
</style>
2、组件-相关api说明
| 参数 | 说明 | 类型 | 默认值 | 必填项 |
|---|---|---|---|---|
| height | 输入框的高度 | String/Number | 25 | 否 |
| dataSource | [{}]-label,value;树形结构 | Array[] | [] | 是 |
| modelValue | 当前选中项内容 | Array | [] | 否 |
| placeholder | 输入框内容 | String | 请输入 | 否 |
| multilevel | 是否开启跨层级模式 | Boolean | false | 否 |
| disabled | 是否开启跨层级禁用 | Boolean | false | 否 |
相关文章:
vue3实现自定义select下拉框内容之城市区域篇
分享-2023年资深前端进阶:前端登顶之巅-最全面的前端知识点梳理总结 *分享一个使用比较久的🪜 需求分析: 1、实现一个区域下拉选项与现有ui组件库不同,支持多选、单选需求 2、支持选中区域后-全选中当前区域下的所有城市信息 3、…...
性能测评:腾讯云轻量应用服务器_CPU内存带宽流量
腾讯云轻量应用服务器性能如何?轻量服务器CPU内存带宽配置高,CPU采用什么型号主频多少?轻量应用服务器会不会比云服务器CVM性能差?腾讯云服务器网详解CPU型号主频、内存、公网带宽和系统盘存储多维对比,相对于CVM云服务…...
python中的迭代器和生成器
一、迭代器 支持迭代的容器,如列表(list)、元组(tuple)、字典(dict)、集合(set)这些序列式容器。 自定义迭代器的类中必须实现以下2个方法: __next__(self)…...
Python-OpenCV中的图像处理-图像阀值
Python-OpenCV中的图像处理-图像阀值 图像阈值单阈值自适应阈值Otsus二值化 图像阈值 单阈值 与名字一样,这种方法非常简单。但像素值高于阈值时,我们给这个像素赋予一个新值(可能是白色),否则我们给它赋予另外一种颜…...
VB+SQL酒店客房管理设计与实现
摘要 二十一世纪是信息技术的时代,计算机已经应用到了各行各业中。采用计算机信息管理技术,可以有效的降低企业的管理成本,提高企业内部的工作效率。 本文从天天宾馆客房客房管理的一般流程出发,设计了一套天天宾馆客房管理信息系统,它可以管理天天宾馆客房中所有的客房的…...
【Linux】从0到1实现一个进度条小程序
个人主页:🍝在肯德基吃麻辣烫 我的gitee:gitee仓库 分享一句喜欢的话:热烈的火焰,冰封在最沉默的火山深处 文章目录 前言一、理解回车 \r 和换行 \n二、初步认识缓冲区1. 认识第一个函数:sleep2.观察缓冲区…...
江南大学轴承数据故障诊断(利用一维CNN进行故障诊断,代码和数据放在压缩包,无需修改任何东西,解压缩后直接运行,有详细注释)
1.江南大学轴承数据集介绍 采样频率:50khz,采样时间:10s 转速:600 800 1000/rpm 内圈:ib 外圈:ob 滚动体:tb 正常:N 以600转速下的内圈故障数据为例展示: 开始数据…...
【网络基础实战之路】基于BGP协议连接三个AS区域的实战详解
系列文章传送门: 【网络基础实战之路】设计网络划分的实战详解 【网络基础实战之路】一文弄懂TCP的三次握手与四次断开 【网络基础实战之路】基于MGRE多点协议的实战详解 【网络基础实战之路】基于OSPF协议建立两个MGRE网络的实验详解 【网络基础实战之路】基于…...
基于Python爬虫+词云图+情感分析对某东上完美日记的用户评论分析
🤵♂️ 个人主页:艾派森的个人主页 ✍🏻作者简介:Python学习者 🐋 希望大家多多支持,我们一起进步!😄 如果文章对你有帮助的话, 欢迎评论 💬点赞Ǵ…...
Day 26 C++ list容器(链表)
文章目录 list基本概念定义结构双向迭代器优点缺点List和vector区别存储结构内存管理迭代器稳定性随机访问效率 list构造函数——创建list容器函数原型示例 list 赋值和交换函数原型 list 大小操作函数原型示例 list 插入和删除函数原型示例 list 数据存取函数原型注意示例 lis…...
【深度学习注意力机制系列】—— SKNet注意力机制(附pytorch实现)
SKNet(Selective Kernel Network)是一种用于图像分类和目标检测任务的深度神经网络架构,其核心创新是引入了选择性的多尺度卷积核(Selective Kernel)以及一种新颖的注意力机制,从而在不增加网络复杂性的情况…...
Markdown语法和表情
Markdown语法和表情 1. 标题2. 段落3. 加粗和斜体4.分隔线5.删除线6.下划线7.引用8.列表9.链接10. 图片11. 代码12.Markdown 表格其他1.支持的 HTML 元素2.转义3.公式 Markdown表情参考 Markdown 是一种轻量级的标记语言,用于简洁地编写文本并转换为HTML。它的语法简…...
CSDN编纂目录索引跳转设置
CSDN编纂目录索引跳转设置 文章目录 题目第一小节第二小节第三小节结论 题目 第一小节 第二小节 第三小节 结论...
cpu的架构
明天继续搞一下cache,还有后面的, 下面是cpu框架图 开始解释cpu 1.控制器 控制器又称为控制单元(Control Unit,简称CU),下面是控制器的组成 1.指令寄存器IR:是用来存放当前正在执行的的一条指令。当一条指令需要被执行时,先按…...
FastAPI和Flask:构建RESTful API的比较分析
Python 是一种功能强大的编程语言,广泛应用于 Web 开发领域。FastAPI 和 Flask 是 Python Web 开发中最受欢迎的两个框架。本文将对 FastAPI 和 Flask 进行综合对比,探讨它们在语法和表达能力、生态系统和社区支持、性能和扩展性、开发工具和调试支持、安…...
用康虎云报表打印二维码
用康虎云报表打印二维码 1 安装: 下载地址: https://www.khcloud.net/cfprint_download, 选择Odoo免代码报表模块和自定义SQL报表模块 下载下来后解压缩,一共有四个模块 cf_report_designer # 报表设计模块 cf_sale_print_ext # 演示模块 cf_sql_report cfprint …...
网盘直链下载助手
一、插件介绍 1.介绍 这是一款免费开源获取网盘文件真实下载地址的油猴脚本,基于 PCSAPI,支持 Windows,Mac,Linux 等多平台,支持 IDM,XDown,Aria2 等多线程下载工具,支持 JSON-RPC…...
【EI复现】售电市场环境下电力用户选择售电公司行为研究(Matlab代码实现)
💥💥💞💞欢迎来到本博客❤️❤️💥💥 🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。 ⛳️座右铭&a…...
并发——何谓悲观锁与乐观锁
乐观锁对应于生活中乐观的人总是想着事情往好的方向发展,悲观锁对应于生活中悲观的人总是想着事情往坏的方向发展。这两种人各有优缺点,不能不以场景而定说一种人好于另外一种人。 悲观锁 总是假设最坏的情况,每次去拿数据的时候都认为别人会…...
【C++】模板
1.模板的概念 2.函数模板基本语法 3.未完待续。。。 https://www.bilibili.com/video/BV1et411b73Z?p169&spm_id_frompageDriver&vd_sourcefb8dcae0aee3f1aab700c21099045395...
生成xcframework
打包 XCFramework 的方法 XCFramework 是苹果推出的一种多平台二进制分发格式,可以包含多个架构和平台的代码。打包 XCFramework 通常用于分发库或框架。 使用 Xcode 命令行工具打包 通过 xcodebuild 命令可以打包 XCFramework。确保项目已经配置好需要支持的平台…...
【Python】 -- 趣味代码 - 小恐龙游戏
文章目录 文章目录 00 小恐龙游戏程序设计框架代码结构和功能游戏流程总结01 小恐龙游戏程序设计02 百度网盘地址00 小恐龙游戏程序设计框架 这段代码是一个基于 Pygame 的简易跑酷游戏的完整实现,玩家控制一个角色(龙)躲避障碍物(仙人掌和乌鸦)。以下是代码的详细介绍:…...
阿里云ACP云计算备考笔记 (5)——弹性伸缩
目录 第一章 概述 第二章 弹性伸缩简介 1、弹性伸缩 2、垂直伸缩 3、优势 4、应用场景 ① 无规律的业务量波动 ② 有规律的业务量波动 ③ 无明显业务量波动 ④ 混合型业务 ⑤ 消息通知 ⑥ 生命周期挂钩 ⑦ 自定义方式 ⑧ 滚的升级 5、使用限制 第三章 主要定义 …...
Cesium1.95中高性能加载1500个点
一、基本方式: 图标使用.png比.svg性能要好 <template><div id"cesiumContainer"></div><div class"toolbar"><button id"resetButton">重新生成点</button><span id"countDisplay&qu…...
Java 二维码
Java 二维码 **技术:**谷歌 ZXing 实现 首先添加依赖 <!-- 二维码依赖 --><dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.5.1</version></dependency><de…...
人工智能--安全大模型训练计划:基于Fine-tuning + LLM Agent
安全大模型训练计划:基于Fine-tuning LLM Agent 1. 构建高质量安全数据集 目标:为安全大模型创建高质量、去偏、符合伦理的训练数据集,涵盖安全相关任务(如有害内容检测、隐私保护、道德推理等)。 1.1 数据收集 描…...
c# 局部函数 定义、功能与示例
C# 局部函数:定义、功能与示例 1. 定义与功能 局部函数(Local Function)是嵌套在另一个方法内部的私有方法,仅在包含它的方法内可见。 • 作用:封装仅用于当前方法的逻辑,避免污染类作用域,提升…...
在鸿蒙HarmonyOS 5中使用DevEco Studio实现指南针功能
指南针功能是许多位置服务应用的基础功能之一。下面我将详细介绍如何在HarmonyOS 5中使用DevEco Studio实现指南针功能。 1. 开发环境准备 确保已安装DevEco Studio 3.1或更高版本确保项目使用的是HarmonyOS 5.0 SDK在项目的module.json5中配置必要的权限 2. 权限配置 在mo…...
密码学基础——SM4算法
博客主页:christine-rr-CSDN博客 专栏主页:密码学 📌 【今日更新】📌 对称密码算法——SM4 目录 一、国密SM系列算法概述 二、SM4算法 2.1算法背景 2.2算法特点 2.3 基本部件 2.3.1 S盒 2.3.2 非线性变换 编辑…...
WEB3全栈开发——面试专业技能点P4数据库
一、mysql2 原生驱动及其连接机制 概念介绍 mysql2 是 Node.js 环境中广泛使用的 MySQL 客户端库,基于 mysql 库改进而来,具有更好的性能、Promise 支持、流式查询、二进制数据处理能力等。 主要特点: 支持 Promise / async-await…...
